]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/48822 (G++ gets stucks and never finishes compilati...
authorRichard Guenther <rguenther@suse.de>
Mon, 4 Jul 2011 14:24:10 +0000 (14:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Jul 2011 14:24:10 +0000 (14:24 +0000)
2011-07-04  Richard Guenther  <rguenther@suse.de>

        Backport from mainline
        2011-05-02  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/48822
* tree-ssa-sccvn.c (set_ssa_val_to): Never go up the lattice.

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

From-SVN: r175813

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

index 440ce2a85af0ed4fe0c30fb1d5325d72c1573c13..48b42087e22366d5698a4644ed3157cbbb09ec91 100644 (file)
@@ -1,3 +1,11 @@
+2011-07-04  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2011-05-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/48822
+       * tree-ssa-sccvn.c (set_ssa_val_to): Never go up the lattice.
+
 2011-07-04  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
index babb1fc487ac538396e1fef28a107c57033dd782..089452e151ee375daef5434dfe42fce24600a8f5 100644 (file)
@@ -1,3 +1,11 @@
+2011-07-04  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2011-05-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/48822
+       * gcc.dg/torture/pr48822.c: New testcase.
+
 2011-07-04  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr48822.c b/gcc/testsuite/gcc.dg/torture/pr48822.c
new file mode 100644 (file)
index 0000000..b619f36
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+void foo (int *, int *);
+int bar ()
+{
+  int a = 0;
+  int b = 0;
+  if (b != 0)
+    {
+      int ax = a;
+      int bx = b;
+      while (bx != 0)
+       {
+         int tem = ax % bx;
+         ax = bx;
+         bx = tem;
+       }
+    }
+  foo (&a, &b);
+}
index 74fc0625c11fb8da450fc44419d27818a6a14bc6..fe7862d2ef069c02dede72f734966e5c3ab07d98 100644 (file)
@@ -1805,12 +1805,26 @@ print_scc (FILE *out, VEC (tree, heap) *scc)
 static inline bool
 set_ssa_val_to (tree from, tree to)
 {
-  tree currval;
+  tree currval = SSA_VAL (from);
 
-  if (from != to
-      && TREE_CODE (to) == SSA_NAME
-      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
-    to = from;
+  if (from != to)
+    {
+      if (currval == from)
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           {
+             fprintf (dump_file, "Not changing value number of ");
+             print_generic_expr (dump_file, from, 0);
+             fprintf (dump_file, " from VARYING to ");
+             print_generic_expr (dump_file, to, 0);
+             fprintf (dump_file, "\n");
+           }
+         return false;
+       }
+      else if (TREE_CODE (to) == SSA_NAME
+              && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
+       to = from;
+    }
 
   /* The only thing we allow as value numbers are VN_TOP, ssa_names
      and invariants.  So assert that here.  */
@@ -1827,8 +1841,6 @@ set_ssa_val_to (tree from, tree to)
       print_generic_expr (dump_file, to, 0);
     }
 
-  currval = SSA_VAL (from);
-
   if (currval != to  && !operand_equal_p (currval, to, OEP_PURE_SAME))
     {
       VN_INFO (from)->valnum = to;