re PR tree-optimization/46288 (ICE: SIGSEGV in walk_gimple_op (gimple.c:2857) with -O -fno-tree-dce and __builtin_expect())

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
This commit is contained in:
Richard Guenther 2010-11-03 16:58:50 +00:00 committed by Richard Biener
parent b7fa98e27b
commit 44cb6d4df4
4 changed files with 30 additions and 3 deletions

View 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

View 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);

View 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

View File

@ -0,0 +1,8 @@
/* { dg-do compile } */
/* { dg-options "-O -fno-tree-dce" } */
void foo (int i)
{
__builtin_expect (i, i);
}