public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR46288
Date: Wed, 03 Nov 2010 17:10:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1011031757080.23074@zhemvz.fhfr.qr> (raw)


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);
+ }
+ 

                 reply	other threads:[~2010-11-03 16:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1011031757080.23074@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).