OSDN Git Service

PR tree-optimization/26213
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Feb 2006 19:22:58 +0000 (19:22 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 10 Feb 2006 19:22:58 +0000 (19:22 +0000)
* tree-ssa-threadedge.c (simplify_control_stmt_condition): Do not
loop trying to follow SSA_NAME_VALUE chains.

* gcc.c-torture/compile/pr26213.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr26213.c [new file with mode: 0644]
gcc/tree-ssa-threadedge.c

index 59f2670..e9225a4 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-10  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/26213
+       * tree-ssa-threadedge.c (simplify_control_stmt_condition): Do not
+       loop trying to follow SSA_NAME_VALUE chains.
+
 2006-02-10  Richard Guenther  <rguenther@suse.de>
 
        * tree-dfa.c (get_ref_base_and_extent): When computing maxsize
index 28b84e4..b158d4a 100644 (file)
@@ -1,3 +1,7 @@
+2006-02-10  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/compile/pr26213.c: New test.
+
 2006-02-10  Steven G. Kargl  <kargls@comcast.net>
 
        gfortran.dg/null_1.f90: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr26213.c b/gcc/testsuite/gcc.c-torture/compile/pr26213.c
new file mode 100644 (file)
index 0000000..7a6600c
--- /dev/null
@@ -0,0 +1,15 @@
+void
+xnanosleep (_Bool overflow)
+{
+  struct { int tv_nsec; } ts_sleep;
+  if (0 <= ts_sleep.tv_nsec)
+    overflow |= 1;
+
+  for (;;)
+    {
+      if (overflow)
+        ts_sleep.tv_nsec = 0;
+      if (foo (ts_sleep))
+        break;
+    }
+}
index b8d4b13..cc98867 100644 (file)
@@ -441,10 +441,14 @@ simplify_control_stmt_condition (edge e,
     {
       cached_lhs = cond;
 
-      /* Get the variable's current value from the equivalency chains.  */
-      while (cached_lhs
-            && TREE_CODE (cached_lhs) == SSA_NAME
-            && SSA_NAME_VALUE (cached_lhs))
+      /* Get the variable's current value from the equivalency chains.
+
+        It is possible to get loops in the SSA_NAME_VALUE chains
+        (consider threading the backedge of a loop where we have
+        a loop invariant SSA_NAME used in the condition.  */
+      if (cached_lhs
+         && TREE_CODE (cached_lhs) == SSA_NAME
+         && SSA_NAME_VALUE (cached_lhs))
        cached_lhs = SSA_NAME_VALUE (cached_lhs);
 
       /* If we're dominated by a suitable ASSERT_EXPR, then