]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/31691 (optimized code taking the wrong branch)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Thu, 17 May 2007 13:30:15 +0000 (15:30 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 17 May 2007 13:30:15 +0000 (13:30 +0000)
PR rtl-optimization/31691
* combine.c (simplify_set): Build a new src pattern instead of
substituting its operands in the COMPARE case.

From-SVN: r124799

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

index 9ca4d69e6ccf407bf83a8155a454cd294588b839..e7b4c9d0261ccf7fdc2969577e4bb55fe6f0af76 100644 (file)
@@ -1,3 +1,9 @@
+2007-05-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR rtl-optimization/31691
+       * combine.c (simplify_set): Build a new src pattern instead of
+       substituting its operands in the COMPARE case.
+
 2007-05-16  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
index 370b89dcd98d4681a561a8aedbae0d1f1d360196..87499445d091cb15c306cc1e532dbb291cc3a7e9 100644 (file)
@@ -5440,14 +5440,14 @@ simplify_set (rtx x)
        }
       else if (GET_MODE (op0) == compare_mode && op1 == const0_rtx)
        {
-         SUBST(SET_SRC (x), op0);
+         SUBST (SET_SRC (x), op0);
          src = SET_SRC (x);
-        }
-      else
+       }
+      /* Otherwise, update the COMPARE if needed.  */
+      else if (XEXP (src, 0) != op0 || XEXP (src, 1) != op1)
        {
-         /* Otherwise, update the COMPARE if needed.  */
-         SUBST (XEXP (src, 0), op0);
-         SUBST (XEXP (src, 1), op1);
+         SUBST (SET_SRC (x), gen_rtx_COMPARE (compare_mode, op0, op1));
+         src = SET_SRC (x);
        }
     }
   else
index a5c3530c56a851882497075629798ee6c1ec7041..e71356e5f4627e6cbdb46b389ab923e3e49c6b0b 100644 (file)
@@ -1,3 +1,7 @@
+2007-05-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.c-torture/execute/20070517-1.c: New test.
+
 2007-05-16  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gcc.c-torture/execute/20070517-1.c b/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
new file mode 100644 (file)
index 0000000..c81cbc6
--- /dev/null
@@ -0,0 +1,41 @@
+/* PR rtl-optimization/31691 */
+/* Origin: Chi-Hua Chen <stephaniechc-gccbug@yahoo.com> */
+
+extern void abort (void);
+
+static int get_kind(int) __attribute__ ((noinline));
+
+static int get_kind(int v)
+{
+  volatile int k = v;
+  return k;
+}
+
+static int some_call(void) __attribute__ ((noinline));
+
+static int some_call(void)
+{
+  return 0;
+}
+
+static void example (int arg)
+{
+  int tmp, kind = get_kind (arg);
+
+  if (kind == 9 || kind == 10 || kind == 5)
+    {
+      if (some_call() == 0)
+        {
+          if (kind == 9 || kind == 10)
+            tmp = arg;
+          else
+            abort();
+        }
+    }
+} 
+
+int main(void)
+{
+  example(10);
+  return 0;
+}