re PR rtl-optimization/60116 (wrong code at -Os on x86_64-linux-gnu in 32-bit mode)
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 12 Feb 2014 08:49:55 +0000 (08:49 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 12 Feb 2014 08:49:55 +0000 (08:49 +0000)
PR rtl-optimization/60116
* combine.c (try_combine): Also remove dangling REG_DEAD notes on the
other_insn once the combination has been validated.

From-SVN: r207713

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20140212-1.c [new file with mode: 0644]

index 9b50158..a92902b 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/60116
+       * combine.c (try_combine): Also remove dangling REG_DEAD notes on the
+       other_insn once the combination has been validated.
+
 2014-02-11  Jan Hubicka  <hubicka@ucw.cz>
 
        PR lto/59468
index fd4294b..f6e1dbc 100644 (file)
@@ -3894,14 +3894,15 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p,
 
       PATTERN (undobuf.other_insn) = other_pat;
 
-      /* If any of the notes in OTHER_INSN were REG_UNUSED, ensure that they
-        are still valid.  Then add any non-duplicate notes added by
-        recog_for_combine.  */
+      /* If any of the notes in OTHER_INSN were REG_DEAD or REG_UNUSED,
+        ensure that they are still valid.  Then add any non-duplicate
+        notes added by recog_for_combine.  */
       for (note = REG_NOTES (undobuf.other_insn); note; note = next)
        {
          next = XEXP (note, 1);
 
-         if (REG_NOTE_KIND (note) == REG_UNUSED
+         if ((REG_NOTE_KIND (note) == REG_DEAD
+              || REG_NOTE_KIND (note) == REG_UNUSED)
              && ! reg_set_p (XEXP (note, 0), PATTERN (undobuf.other_insn)))
            remove_note (undobuf.other_insn, note);
        }
index 2505b6a..5555d3e 100644 (file)
@@ -1,3 +1,7 @@
+2014-02-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/execute/20140212-1.c: New test.
+
 2014-02-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60047
diff --git a/gcc/testsuite/gcc.c-torture/execute/20140212-1.c b/gcc/testsuite/gcc.c-torture/execute/20140212-1.c
new file mode 100644 (file)
index 0000000..8f1f84f
--- /dev/null
@@ -0,0 +1,37 @@
+/* PR rtl-optimization/60116 */
+/* Reported by Zhendong Su <su@cs.ucdavis.edu> */
+
+extern void abort (void);
+
+int a, b, c, d = 1, e, f = 1, h, i, k;
+char g, j;
+
+void
+fn1 (void)
+{
+  int l;
+  e = 0;
+  c = 0;
+  for (;;)
+    {
+      k = a && b;
+      j = k * 54;
+      g = j * 147;
+      l = ~g + (long long) e && 1;
+      if (d)
+       c = l;
+      else
+       h = i = l * 9UL;
+      if (f)
+       return;
+    }
+}
+
+int
+main (void)
+{
+  fn1 ();
+  if (c != 1)
+    abort ();
+  return 0;
+}