OSDN Git Service

PR rtl-optimization/31691
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 May 2007 13:29:10 +0000 (13:29 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 May 2007 13:29:10 +0000 (13:29 +0000)
* combine.c (simplify_set): Build a new src pattern instead of
substituting its operands in the COMPARE case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124797 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 247a42d..8286104 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-17  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * tree-vrp.c (finalize_jump_threads): Do not care about dominance info.
index 99da26d..7589aac 100644 (file)
@@ -5343,14 +5343,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 a78f675..7a219b3 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-17  Daniel Franke <franke.daniel@gmail.com>
 
        PR fortran/31919
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;
+}