]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/36978 (ICE in gimple_cond_set_lhs for -O2 -funswitch-loops...
authorRichard Guenther <rguenther@suse.de>
Thu, 31 Jul 2008 14:12:24 +0000 (14:12 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 31 Jul 2008 14:12:24 +0000 (14:12 +0000)
2008-07-31  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/36978
* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Do not fold
the generated condition.

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

From-SVN: r138415

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr36978.c [new file with mode: 0644]
gcc/tree-ssa-loop-unswitch.c

index cb7a67b651391f7ad165bfb50b959baadad6bd5a..c83a2faa81cdeff93bf19ab01ca6d19effd4cf7d 100644 (file)
@@ -1,3 +1,9 @@
+2008-07-31  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/36978
+       * tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Do not fold
+       the generated condition.
+
 2008-07-31  Richard Guenther  <rguenther@suse.de>
 
        * passes.c (init_optimization_passes): Always call
index ccbd9711809ac475a45e3a8ef82d778854929034..f6e855abd083d7676a9f95d678007e6397395eca 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-31  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/36978
+       * gcc.dg/torture/pr36978.c: New testcase.
+
 2008-07-31  Arnaud Charlet  <charlet@adacore.com>
 
        * gnat.dg/sync_iface_test.ad[s,b]: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr36978.c b/gcc/testsuite/gcc.dg/torture/pr36978.c
new file mode 100644 (file)
index 0000000..cd1af4e
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-funswitch-loops" } */
+
+unsigned short status;
+void foo (const _Bool flag)
+{
+  if (status == 2 || status == 7)
+    {
+      while (status != 2 && (status != 7 || !flag))
+       {
+       }
+    }
+}
+
index 8ece4aca4ab3f8f3b614ce549ca65ad79e62a013..850270f49c03285d88c07ac1f381d4866834bd29 100644 (file)
@@ -123,8 +123,8 @@ tree_may_unswitch_on (basic_block bb, struct loop *loop)
        return NULL_TREE;
     }
 
-  cond = fold_build2 (gimple_cond_code (stmt), boolean_type_node,
-                     gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
+  cond = build2 (gimple_cond_code (stmt), boolean_type_node,
+                gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
 
   /* To keep the things simple, we do not directly remove the conditions,
      but just replace tests with 0/1.  Prevent the infinite loop where we