]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/56661 (Incorrect code with -O1 -ftree-pre)
authorRichard Biener <rguenther@suse.de>
Wed, 20 Mar 2013 13:26:19 +0000 (13:26 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Mar 2013 13:26:19 +0000 (13:26 +0000)
2013-03-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56661
* tree-ssa-sccvn.c (visit_use): Only value-number calls if
the result does not have to be distinct.

* gcc.dg/torture/pr56661.c: New testcase.

From-SVN: r196825

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr56661.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 217a76d9a003e5d8ebe68d7b96e798494eba7d6b..a238d534be3dc11fd7f0506a4624d7afd40d31ba 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56661
+       * tree-ssa-sccvn.c (visit_use): Only value-number calls if
+       the result does not have to be distinct.
+
 2013-03-20  Richard Biener  <rguenther@suse.de>
 
        * tree-inline.c (copy_tree_body_r): Sync MEM_REF code with
index 29d5d607c5d6b40ff398163c53b764e1135f244f..96c0bc7bbd9c48ce774eb98514d63e18ff2a895e 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56661
+       * gcc.dg/torture/pr56661.c: New testcase.
+
 2013-03-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        PR rtl-optimization/56605
diff --git a/gcc/testsuite/gcc.dg/torture/pr56661.c b/gcc/testsuite/gcc.dg/torture/pr56661.c
new file mode 100644 (file)
index 0000000..6fdaedb
--- /dev/null
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+
+__attribute__((noinline, noclone)) void
+bar (int *b)
+{
+  b[0] = b[1] = b[2] = 1;
+}
+
+__attribute__((noinline, noclone)) int
+baz (int x)
+{
+  if (x != 1)
+    __builtin_abort ();
+}
+
+void
+foo (int x)
+{
+  if (x == 0)
+    {
+      int *b = __builtin_malloc (3 * sizeof (int));
+      while (b[0])
+       ;
+    }
+  else if (x == 1)
+    {
+      int i, j;
+      int *b = __builtin_malloc (3 * sizeof (int));
+      for (i = 0; i < 2; i++)
+       {
+         bar (b);
+         for (j = 0; j < 3; ++j)
+           baz (b[j]);
+         baz (b[0]);
+       }
+    }
+}
+
+int
+main ()
+{
+  int x = 1;
+  asm volatile ("" : "+r" (x));
+  foo (x);
+  return 0;
+}
index 8360cc730008e0bbf419296c3fc14f855c978394..e7aefbf0551dae86f658e1a2d4cfcf74757993b2 100644 (file)
@@ -3506,8 +3506,13 @@ visit_use (tree use)
                     We can value number 2 calls to the same function with the
                     same vuse and the same operands which are not subsequent
                     the same, because there is no code in the program that can
-                    compare the 2 values.  */
-                 || gimple_vdef (stmt)))
+                    compare the 2 values...  */
+                 || (gimple_vdef (stmt)
+                     /* ... unless the call returns a pointer which does
+                        not alias with anything else.  In which case the
+                        information that the values are distinct are encoded
+                        in the IL.  */
+                     && !(gimple_call_return_flags (stmt) & ERF_NOALIAS))))
            changed = visit_reference_op_call (lhs, stmt);
          else
            changed = defs_to_varying (stmt);
This page took 0.101573 seconds and 5 git commands to generate.