summaryrefslogtreecommitdiff
path: root/gcc/reload1.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-10-26 16:53:43 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-10-26 16:53:43 +0000
commitbd5a2c67cfd636b6c78f213c8ee6dac62323eff9 (patch)
tree793d74fec25534f3062be8641413cfa6430d1cf0 /gcc/reload1.c
parent204d2c03acff4bf3b73cb5d2c9578b50c2aac703 (diff)
Add wider_subreg_mode helper functions
This patch adds helper functions that say which of the two modes involved in a subreg is the larger, preferring the outer mode in the event of a tie. It also converts IRA and reload to track modes instead of byte sizes, since this is slightly more convenient when variable-sized modes are added later. 2017-10-26 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * rtl.h (wider_subreg_mode): New function. * ira.h (ira_sort_regnos_for_alter_reg): Take a machine_mode * rather than an unsigned int *. * ira-color.c (regno_max_ref_width): Replace with... (regno_max_ref_mode): ...this new variable. (coalesced_pseudo_reg_slot_compare): Update accordingly. Use wider_subreg_mode. (ira_sort_regnos_for_alter_reg): Likewise. Take a machine_mode * rather than an unsigned int *. * lra-constraints.c (uses_hard_regs_p): Use wider_subreg_mode. (process_alt_operands): Likewise. (invariant_p): Likewise. * lra-spills.c (assign_mem_slot): Likewise. (add_pseudo_to_slot): Likewise. * lra.c (collect_non_operand_hard_regs): Likewise. (add_regs_to_insn_regno_info): Likewise. * reload1.c (regno_max_ref_width): Replace with... (regno_max_ref_mode): ...this new variable. (reload): Update accordingly. Update call to ira_sort_regnos_for_alter_reg. (alter_reg): Update to use regno_max_ref_mode. Call wider_subreg_mode. (init_eliminable_invariants): Update to use regno_max_ref_mode. (scan_paradoxical_subregs): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r254115
Diffstat (limited to 'gcc/reload1.c')
-rw-r--r--gcc/reload1.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/gcc/reload1.c b/gcc/reload1.c
index e2ee2feda93..e15bd8a2c1a 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -97,8 +97,8 @@ static regset_head reg_has_output_reload;
in the current insn. */
static HARD_REG_SET reg_is_output_reload;
-/* Widest width in which each pseudo reg is referred to (via subreg). */
-static unsigned int *reg_max_ref_width;
+/* Widest mode in which each pseudo reg is referred to (via subreg). */
+static machine_mode *reg_max_ref_mode;
/* Vector to remember old contents of reg_renumber before spilling. */
static short *reg_old_renumber;
@@ -830,7 +830,7 @@ reload (rtx_insn *first, int global)
if (ira_conflicts_p)
/* Ask IRA to order pseudo-registers for better stack slot
sharing. */
- ira_sort_regnos_for_alter_reg (temp_pseudo_reg_arr, n, reg_max_ref_width);
+ ira_sort_regnos_for_alter_reg (temp_pseudo_reg_arr, n, reg_max_ref_mode);
for (i = 0; i < n; i++)
alter_reg (temp_pseudo_reg_arr[i], -1, false);
@@ -1252,7 +1252,7 @@ reload (rtx_insn *first, int global)
/* Indicate that we no longer have known memory locations or constants. */
free_reg_equiv ();
- free (reg_max_ref_width);
+ free (reg_max_ref_mode);
free (reg_old_renumber);
free (pseudo_previous_regs);
free (pseudo_forbidden_regs);
@@ -2142,8 +2142,9 @@ alter_reg (int i, int from_reg, bool dont_share_p)
machine_mode mode = GET_MODE (regno_reg_rtx[i]);
unsigned int inherent_size = PSEUDO_REGNO_BYTES (i);
unsigned int inherent_align = GET_MODE_ALIGNMENT (mode);
- unsigned int total_size = MAX (inherent_size, reg_max_ref_width[i]);
- unsigned int min_align = reg_max_ref_width[i] * BITS_PER_UNIT;
+ machine_mode wider_mode = wider_subreg_mode (mode, reg_max_ref_mode[i]);
+ unsigned int total_size = GET_MODE_SIZE (wider_mode);
+ unsigned int min_align = GET_MODE_BITSIZE (reg_max_ref_mode[i]);
int adjust = 0;
something_was_spilled = true;
@@ -4083,9 +4084,9 @@ init_eliminable_invariants (rtx_insn *first, bool do_subregs)
grow_reg_equivs ();
if (do_subregs)
- reg_max_ref_width = XCNEWVEC (unsigned int, max_regno);
+ reg_max_ref_mode = XCNEWVEC (machine_mode, max_regno);
else
- reg_max_ref_width = NULL;
+ reg_max_ref_mode = NULL;
num_eliminable_invariants = 0;
@@ -4404,7 +4405,7 @@ finish_spills (int global)
return something_changed;
}
-/* Find all paradoxical subregs within X and update reg_max_ref_width. */
+/* Find all paradoxical subregs within X and update reg_max_ref_mode. */
static void
scan_paradoxical_subregs (rtx x)
@@ -4427,13 +4428,14 @@ scan_paradoxical_subregs (rtx x)
return;
case SUBREG:
- if (REG_P (SUBREG_REG (x))
- && (GET_MODE_SIZE (GET_MODE (x))
- > reg_max_ref_width[REGNO (SUBREG_REG (x))]))
+ if (REG_P (SUBREG_REG (x)))
{
- reg_max_ref_width[REGNO (SUBREG_REG (x))]
- = GET_MODE_SIZE (GET_MODE (x));
- mark_home_live_1 (REGNO (SUBREG_REG (x)), GET_MODE (x));
+ unsigned int regno = REGNO (SUBREG_REG (x));
+ if (partial_subreg_p (reg_max_ref_mode[regno], GET_MODE (x)))
+ {
+ reg_max_ref_mode[regno] = GET_MODE (x);
+ mark_home_live_1 (regno, GET_MODE (x));
+ }
}
return;