2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-18 01:20:48 +08:00

Fix execute/20071219-1.c regression on H8 due to loss of REG_INC notes in peephole2.

gcc/
	* lra.c (add_auto_inc_notes): Remove function.
	* reload1.c (add_auto_inc_notes): Similarly.  Move into...
	* rtlanal.c (add_auto_inc_notes): New function.
	* rtl.h (add_auto_inc_notes): Add prototype.
	* recog.c (peep2_attempt): Scan and add REG_INC notes to new insns
	as needed.
This commit is contained in:
Jeff Law 2020-05-31 11:16:37 -06:00
parent 05430b9b6a
commit c25d0fa4d7
5 changed files with 34 additions and 54 deletions

@ -2231,34 +2231,6 @@ has_nonexceptional_receiver (void)
return false;
}
/* Process recursively X of INSN and add REG_INC notes if necessary. */
static void
add_auto_inc_notes (rtx_insn *insn, rtx x)
{
enum rtx_code code = GET_CODE (x);
const char *fmt;
int i, j;
if (code == MEM && auto_inc_p (XEXP (x, 0)))
{
add_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0));
return;
}
/* Scan all X sub-expressions. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
add_auto_inc_notes (insn, XEXP (x, i));
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
add_auto_inc_notes (insn, XVECEXP (x, i, j));
}
}
/* Remove all REG_DEAD and REG_UNUSED notes and regenerate REG_INC.
We change pseudos by hard registers without notification of DF and
that can make the notes obsolete. DF-infrastructure does not deal

@ -3501,6 +3501,13 @@ peep2_attempt (basic_block bb, rtx_insn *insn, int match_len, rtx_insn *attempt)
if (as_note)
fixup_args_size_notes (before_try, last, get_args_size (as_note));
/* Scan the new insns for embedded side effects and add appropriate
REG_INC notes. */
if (AUTO_INC_DEC)
for (x = last; x != before_try; x = PREV_INSN (x))
if (NONDEBUG_INSN_P (x))
add_auto_inc_notes (x, PATTERN (x));
/* If we generated a jump instruction, it won't have
JUMP_LABEL set. Recompute after we're done. */
for (x = last; x != before_try; x = PREV_INSN (x))

@ -395,7 +395,6 @@ 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, 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);
static int reloads_conflict (int, int);
@ -9071,28 +9070,3 @@ inc_for_reload (rtx reloadreg, rtx in, rtx value, poly_int64 inc_amount)
emit_insn (gen_sub2_insn (reloadreg, inc));
}
}
static void
add_auto_inc_notes (rtx_insn *insn, rtx x)
{
enum rtx_code code = GET_CODE (x);
const char *fmt;
int i, j;
if (code == MEM && auto_inc_p (XEXP (x, 0)))
{
add_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0));
return;
}
/* Scan all the operand sub-expressions. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
add_auto_inc_notes (insn, XEXP (x, i));
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
add_auto_inc_notes (insn, XVECEXP (x, i, j));
}
}

@ -3429,6 +3429,7 @@ extern rtx single_set_2 (const rtx_insn *, const_rtx);
extern bool contains_symbol_ref_p (const_rtx);
extern bool contains_symbolic_reference_p (const_rtx);
extern bool contains_constant_pool_address_p (const_rtx);
extern void add_auto_inc_notes (rtx_insn *, rtx);
/* Handle the cheap and common cases inline for performance. */

@ -6591,3 +6591,29 @@ tls_referenced_p (const_rtx x)
return true;
return false;
}
/* Process recursively X of INSN and add REG_INC notes if necessary. */
void
add_auto_inc_notes (rtx_insn *insn, rtx x)
{
enum rtx_code code = GET_CODE (x);
const char *fmt;
int i, j;
if (code == MEM && auto_inc_p (XEXP (x, 0)))
{
add_reg_note (insn, REG_INC, XEXP (XEXP (x, 0), 0));
return;
}
/* Scan all X sub-expressions. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
add_auto_inc_notes (insn, XEXP (x, i));
else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
add_auto_inc_notes (insn, XVECEXP (x, i, j));
}
}