From 0cb78959893b418d0e81d62b22e450a09a7ef958 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 21 Dec 2017 06:58:00 +0000 Subject: [PATCH] poly_int: reload.c This patch makes a few small poly_int64 changes to reload.c, such as in the "decomposition" structure. In practice, any port with polynomial-sized modes should be using LRA rather than reload, but it's easier to convert reload anyway than to sprinkle to_constants everywhere. 2017-12-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * reload.h (reload::inc): Change from an int to a poly_int64_pod. * reload.c (combine_reloads, debug_reload_to_stream): Likewise. (decomposition): Change start and end from HOST_WIDE_INT to poly_int64_pod. (decompose, immune_p): Update accordingly. (find_inc_amount): Return a poly_int64 rather than an int. * reload1.c (inc_for_reload): Take the inc_amount as a poly_int64 rather than an int. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r255915 --- gcc/ChangeLog | 13 ++++++++++++ gcc/reload.c | 59 ++++++++++++++++++++++++++++++--------------------- gcc/reload.h | 2 +- gcc/reload1.c | 6 +++--- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fd061b9c2caf..605c74ada55c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-12-21 Richard Sandiford + Alan Hayward + David Sherwood + + * reload.h (reload::inc): Change from an int to a poly_int64_pod. + * reload.c (combine_reloads, debug_reload_to_stream): Likewise. + (decomposition): Change start and end from HOST_WIDE_INT + to poly_int64_pod. + (decompose, immune_p): Update accordingly. + (find_inc_amount): Return a poly_int64 rather than an int. + * reload1.c (inc_for_reload): Take the inc_amount as a poly_int64 + rather than an int. + 2017-12-21 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/reload.c b/gcc/reload.c index 59b0326a4602..0d986f73b346 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -168,8 +168,8 @@ struct decomposition int reg_flag; /* Nonzero if referencing a register. */ int safe; /* Nonzero if this can't conflict with anything. */ rtx base; /* Base address for MEM. */ - HOST_WIDE_INT start; /* Starting offset or register number. */ - HOST_WIDE_INT end; /* Ending offset or register number. */ + poly_int64_pod start; /* Starting offset or register number. */ + poly_int64_pod end; /* Ending offset or register number. */ }; /* Save MEMs needed to copy from one class of registers to another. One MEM @@ -278,7 +278,7 @@ static void find_reloads_address_part (rtx, rtx *, enum reg_class, static rtx find_reloads_subreg_address (rtx, int, enum reload_type, int, rtx_insn *, int *); static void copy_replacements_1 (rtx *, rtx *, int); -static int find_inc_amount (rtx, rtx); +static poly_int64 find_inc_amount (rtx, rtx); static int refers_to_mem_for_reload_p (rtx); static int refers_to_regno_for_reload_p (unsigned int, unsigned int, rtx, rtx *); @@ -1772,7 +1772,7 @@ combine_reloads (void) && (ira_reg_class_max_nregs [(int)rld[i].rclass][(int) rld[i].inmode] == ira_reg_class_max_nregs [(int) rld[output_reload].rclass] [(int) rld[output_reload].outmode]) - && rld[i].inc == 0 + && known_eq (rld[i].inc, 0) && rld[i].reg_rtx == 0 /* Don't combine two reloads with different secondary memory locations. */ @@ -2360,7 +2360,7 @@ static struct decomposition decompose (rtx x) { struct decomposition val; - int all_const = 0; + int all_const = 0, regno; memset (&val, 0, sizeof (val)); @@ -2458,29 +2458,33 @@ decompose (rtx x) case REG: val.reg_flag = 1; - val.start = true_regnum (x); - if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER) + regno = true_regnum (x); + if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER) { /* A pseudo with no hard reg. */ val.start = REGNO (x); val.end = val.start + 1; } else - /* A hard reg. */ - val.end = end_hard_regno (GET_MODE (x), val.start); + { + /* A hard reg. */ + val.start = regno; + val.end = end_hard_regno (GET_MODE (x), regno); + } break; case SUBREG: if (!REG_P (SUBREG_REG (x))) /* This could be more precise, but it's good enough. */ return decompose (SUBREG_REG (x)); - val.reg_flag = 1; - val.start = true_regnum (x); - if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER) + regno = true_regnum (x); + if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER) return decompose (SUBREG_REG (x)); - else - /* A hard reg. */ - val.end = val.start + subreg_nregs (x); + + /* A hard reg. */ + val.reg_flag = 1; + val.start = regno; + val.end = regno + subreg_nregs (x); break; case SCRATCH: @@ -2505,7 +2509,11 @@ immune_p (rtx x, rtx y, struct decomposition ydata) struct decomposition xdata; if (ydata.reg_flag) - return !refers_to_regno_for_reload_p (ydata.start, ydata.end, x, (rtx*) 0); + /* In this case the decomposition structure contains register + numbers rather than byte offsets. */ + return !refers_to_regno_for_reload_p (ydata.start.to_constant (), + ydata.end.to_constant (), + x, (rtx *) 0); if (ydata.safe) return 1; @@ -2536,7 +2544,7 @@ immune_p (rtx x, rtx y, struct decomposition ydata) return 0; } - return (xdata.start >= ydata.end || ydata.start >= xdata.end); + return known_ge (xdata.start, ydata.end) || known_ge (ydata.start, xdata.end); } /* Similar, but calls decompose. */ @@ -7062,7 +7070,7 @@ find_equiv_reg (rtx goal, rtx_insn *insn, enum reg_class rclass, int other, within X, and return the amount INCED is incremented or decremented by. The value is always positive. */ -static int +static poly_int64 find_inc_amount (rtx x, rtx inced) { enum rtx_code code = GET_CODE (x); @@ -7095,8 +7103,8 @@ find_inc_amount (rtx x, rtx inced) { if (fmt[i] == 'e') { - int tem = find_inc_amount (XEXP (x, i), inced); - if (tem != 0) + poly_int64 tem = find_inc_amount (XEXP (x, i), inced); + if (maybe_ne (tem, 0)) return tem; } if (fmt[i] == 'E') @@ -7104,8 +7112,8 @@ find_inc_amount (rtx x, rtx inced) int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) { - int tem = find_inc_amount (XVECEXP (x, i, j), inced); - if (tem != 0) + poly_int64 tem = find_inc_amount (XVECEXP (x, i, j), inced); + if (maybe_ne (tem, 0)) return tem; } } @@ -7266,8 +7274,11 @@ debug_reload_to_stream (FILE *f) if (rld[r].nongroup) fprintf (f, ", nongroup"); - if (rld[r].inc != 0) - fprintf (f, ", inc by %d", rld[r].inc); + if (maybe_ne (rld[r].inc, 0)) + { + fprintf (f, ", inc by "); + print_dec (rld[r].inc, f, SIGNED); + } if (rld[r].nocombine) fprintf (f, ", can't combine"); diff --git a/gcc/reload.h b/gcc/reload.h index 87e786ed06ff..2019db8b761b 100644 --- a/gcc/reload.h +++ b/gcc/reload.h @@ -97,7 +97,7 @@ struct reload /* Positive amount to increment or decrement by if reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC. Ignored otherwise (don't assume it is zero). */ - int inc; + poly_int64_pod inc; /* A reg for which reload_in is the equivalent. If reload_in is a symbol_ref which came from reg_equiv_constant, then this is the pseudo diff --git a/gcc/reload1.c b/gcc/reload1.c index f17edda9721a..9557e3d154d8 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -398,7 +398,7 @@ static void emit_reload_insns (struct insn_chain *); static void delete_output_reload (rtx_insn *, int, int, rtx); static void delete_address_reloads (rtx_insn *, rtx_insn *); static void delete_address_reloads_1 (rtx_insn *, rtx, rtx_insn *); -static void inc_for_reload (rtx, rtx, rtx, int); +static void inc_for_reload (rtx, rtx, rtx, poly_int64); static void add_auto_inc_notes (rtx_insn *, rtx); static void substitute (rtx *, const_rtx, rtx); static bool gen_reload_chain_without_interm_reg_p (int, int); @@ -9075,7 +9075,7 @@ delete_address_reloads_1 (rtx_insn *dead_insn, rtx x, rtx_insn *current_insn) This cannot be deduced from VALUE. */ static void -inc_for_reload (rtx reloadreg, rtx in, rtx value, int inc_amount) +inc_for_reload (rtx reloadreg, rtx in, rtx value, poly_int64 inc_amount) { /* REG or MEM to be copied and incremented. */ rtx incloc = find_replacement (&XEXP (value, 0)); @@ -9105,7 +9105,7 @@ inc_for_reload (rtx reloadreg, rtx in, rtx value, int inc_amount) if (GET_CODE (value) == PRE_DEC || GET_CODE (value) == POST_DEC) inc_amount = -inc_amount; - inc = GEN_INT (inc_amount); + inc = gen_int_mode (inc_amount, Pmode); } /* If this is post-increment, first copy the location to the reload reg. */ -- 2.43.5