public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR46288
@ 2010-11-03 17:10 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2010-11-03 17:10 UTC (permalink / raw)
  To: gcc-patches


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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.

Index: gcc/predict.c
===================================================================
*** gcc/predict.c	(revision 166249)
--- gcc/predict.c	(working copy)
*************** strip_predict_hints (void)
*** 1329,1337 ****
  		  && 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);
  		}
  	    }
  	  gsi_next (&bi);
--- 1329,1345 ----
  		  && gimple_call_num_args (stmt) == 2)
  		{
  		  var = gimple_call_lhs (stmt);
! 		  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: gcc/testsuite/gcc.dg/pr46288.c
===================================================================
*** gcc/testsuite/gcc.dg/pr46288.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr46288.c	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -fno-tree-dce" } */
+ 
+ void foo (int i)
+ {
+   __builtin_expect (i, i);
+ }
+ 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-11-03 16:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-03 17:10 [PATCH] Fix PR46288 Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).