]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix execute/20071219-1.c regression on H8 due to loss of REG_INC notes in peephole2.
authorJeff Law <law@redhat.com>
Sun, 31 May 2020 17:16:37 +0000 (11:16 -0600)
committerJeff Law <law@redhat.com>
Sun, 31 May 2020 17:18:15 +0000 (11:18 -0600)
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.

gcc/lra.c
gcc/recog.c
gcc/reload1.c
gcc/rtl.h
gcc/rtlanal.c

index 5e8b75b1fdaeeca955cb160cd202b850a0b13f71..3435cff6a1dc01dfee0af5865d50dadd9f268045 100644 (file)
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -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
index 8c098cf5b0fe8b4378a58ff6517b4b27998c0613..25f19b1b1cf3f440047fbe56587aa0a9e066b5a1 100644 (file)
@@ -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))
index 88f4727d5453dd0b406fc22838274a3a7bb1eb5c..19a64f2542a86986b89c451c2d156e540d151a19 100644 (file)
@@ -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));
     }
 }
-\f
-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));
-    }
-}
index b0b1aacd2e8ff4155a7ed49e53a0f061eaba3361..0872cc408eb177f42083204764e69b2268cf0840 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -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.  */
 
index 9ff17caaba0ddb55fcbf4ba5f9996bac038cb3f8..1d2874d867272b878a3bdf39e2b909f84ad73329 100644 (file)
@@ -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));
+    }
+}