]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove the REG_EQUAL note if we don't know its invariant status.
authorH.J. Lu <hongjiu.lu@intel.com>
Thu, 18 Mar 2010 13:13:42 +0000 (13:13 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Thu, 18 Mar 2010 13:13:42 +0000 (06:13 -0700)
gcc/

2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>

Backport from mainline:
2010-03-18  Steven Bosscher  <steven@gcc.gnu.org>
    Eric Botcazou  <ebotcazou@adacore.com>

PR rtl-optimization/43360
* loop-invariant.c (move_invariant_reg): Remove the REG_EQUAL
note if we don't know its invariant status.

gcc/testsuite/

2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>

Backport from mainline:
2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>

PR rtl-optimization/43360
* gcc.dg/torture/pr43360.c: New.

From-SVN: r157540

gcc/ChangeLog
gcc/loop-invariant.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr43360.c [new file with mode: 0644]

index ac8b9f3aa29b021546744b836ede549af042c4b8..3f8f5aee7f42ec2b0a3a64dcce383697730502c4 100644 (file)
@@ -1,3 +1,13 @@
+2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline:
+       2010-03-18  Steven Bosscher  <steven@gcc.gnu.org>
+                   Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/43360
+       * loop-invariant.c (move_invariant_reg): Remove the REG_EQUAL
+       note if we don't know its invariant status.
+
 2010-03-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/alpha.c (override_options): Fix -mtune error message.
index ce3fb7309bfaa9a4ade73f0bf2f362a1f6a67c92..e0623855721a9b702dad694537ddb956ea1007fe 100644 (file)
@@ -1203,14 +1203,16 @@ move_invariant_reg (struct loop *loop, unsigned invno)
       emit_insn_after (gen_move_insn (dest, reg), inv->insn);
       reorder_insns (inv->insn, inv->insn, BB_END (preheader));
 
-      /* If there is a REG_EQUAL note on the insn we just moved, and
-        insn is in a basic block that is not always executed, the note
-        may no longer be valid after we move the insn.
-        Note that uses in REG_EQUAL notes are taken into account in
-        the computation of invariants.  Hence it is safe to retain the
-        note even if the note contains register references.  */
-      if (! inv->always_executed
-         && (note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX)))
+      /* If there is a REG_EQUAL note on the insn we just moved, and the
+        insn is in a basic block that is not always executed or the note
+        contains something for which we don't know the invariant status,
+        the note may no longer be valid after we move the insn.  Note that
+        uses in REG_EQUAL notes are taken into account in the computation
+        of invariants, so it is safe to retain the note even if it contains
+        register references for which we know the invariant status.  */
+      if ((note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX))
+         && (!inv->always_executed
+             || !check_maybe_invariant (XEXP (note, 0))))
        remove_note (inv->insn, note);
     }
   else
index ef1698330bcbc254c66b52b8b524ab291396282a..4a24f2889ed0501e2fd76418c8d69473dfe21d6f 100644 (file)
@@ -1,3 +1,11 @@
+2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline:
+       2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR rtl-optimization/43360
+       * gcc.dg/torture/pr43360.c: New.
+
 2010-03-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.target/arm/sibcall-1.c: Allow PLT to appear with pic code.
diff --git a/gcc/testsuite/gcc.dg/torture/pr43360.c b/gcc/testsuite/gcc.dg/torture/pr43360.c
new file mode 100644 (file)
index 0000000..9ed9872
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+int l_5_5_2 = 4;
+int g_3[1][1];
+
+void func_1 (void)
+{
+  for (g_3[0][0] = 1; g_3[0][0] < 8; g_3[0][0] += 7) {
+    int *l_6 = &g_3[0][0];
+    *l_6 = l_5_5_2;
+  }
+}
+
+int main (void)
+{
+  func_1 ();
+  if (g_3[0][0] != 11)
+      __builtin_abort ();
+  return 0;
+}