re PR tree-optimization/46288 (ICE: SIGSEGV in walk_gimple_op (gimple.c:2857) with...
authorRichard Guenther <rguenther@suse.de>
Wed, 3 Nov 2010 16:58:50 +0000 (16:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 3 Nov 2010 16:58:50 +0000 (16:58 +0000)
2010-11-03  Richard Guenther  <rguenther@suse.de>

PR middle-end/46288
* predict.c (strip_predict_hints): Simply DCE builtin expect if
the result is unused.

* gcc.dg/pr46288.c: New testcase.

From-SVN: r166258

gcc/ChangeLog
gcc/predict.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr46288.c [new file with mode: 0644]

index 73198e3dc7a8885e0f5da4d0d25124c145c8c761..e62aaabb410c6425206606af2b22c9288a26fd2a 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-03  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/46288
+       * predict.c (strip_predict_hints): Simply DCE builtin expect if
+       the result is unused.
+
 2010-11-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/46009
index eb91b87819d6e1d5e279bd4740366498700e121b..beceb0f26801aca39cad67b0cedcad37c7272825 100644 (file)
@@ -1329,9 +1329,17 @@ strip_predict_hints (void)
                  && gimple_call_num_args (stmt) == 2)
                {
                  var = gimple_call_lhs (stmt);
-                 ass_stmt = gimple_build_assign (var, gimple_call_arg (stmt, 0));
-
-                 gsi_replace (&bi, ass_stmt, true);
+                 if (var)
+                   {
+                     ass_stmt
+                       = gimple_build_assign (var, gimple_call_arg (stmt, 0));
+                     gsi_replace (&bi, ass_stmt, true);
+                   }
+                 else
+                   {
+                     gsi_remove (&bi, true);
+                     continue;
+                   }
                }
            }
          gsi_next (&bi);
index 5e266c1a8a4bb0943216b9618eacbf2d5903d6fb..61c24f9fb752ef8b5dd455afd3196b73e609fd32 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-03  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/46288
+       * gcc.dg/pr46288.c: New testcase.
+
 2010-11-03  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/44807
diff --git a/gcc/testsuite/gcc.dg/pr46288.c b/gcc/testsuite/gcc.dg/pr46288.c
new file mode 100644 (file)
index 0000000..24c8874
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce" } */
+
+void foo (int i)
+{
+  __builtin_expect (i, i);
+}
+