public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix noreturn predictor to also work with no regular exits
@ 2011-06-09 12:12 Richard Guenther
  2011-06-09 14:06 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2011-06-09 12:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka


This is a complementary fix for the leslie3d problem.  For functions
without a regular exit (for example one that exits with exit (0))
we do not apply noreturn predictors.   The following patch notices
that edges to noreturn calls are still unlikely if they have
exactly one predecessor and is not fallthru.  In the leslie3d
case this avoids predicting the edges to STOP but still correctly
predicts the edges to the exceptional noreturn functions.

Bootstrap and regtest running on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2011-06-09  Richard Guenther  <rguenther@suse.de>

	* predict.c (tree_bb_level_predictions): For functions with
	no regular exit still predict the edge to a block with a noreturn
	function as not taken if it is not a fallthru edge.

Index: gcc/predict.c
===================================================================
--- gcc/predict.c	(revision 174746)
+++ gcc/predict.c	(working copy)
@@ -1613,10 +1613,18 @@ tree_bb_level_predictions (void)
 
 	  if (is_gimple_call (stmt))
 	    {
-	      if ((gimple_call_flags (stmt) & ECF_NORETURN)
-	          && has_return_edges)
-		predict_paths_leading_to (bb, PRED_NORETURN,
-					  NOT_TAKEN);
+	      if ((gimple_call_flags (stmt) & ECF_NORETURN))
+		{
+	          if (has_return_edges)
+		    predict_paths_leading_to (bb, PRED_NORETURN,
+					      NOT_TAKEN);
+		  else if (single_pred_p (bb))
+		    {
+		      edge e = single_pred_edge (bb);
+		      if (!(e->flags & EDGE_FALLTHRU))
+			predict_edge_def (e, PRED_NORETURN, NOT_TAKEN);
+		    }
+		}
 	      decl = gimple_call_fndecl (stmt);
 	      if (decl
 		  && lookup_attribute ("cold",

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix noreturn predictor to also work with no regular exits
  2011-06-09 12:12 [PATCH] Fix noreturn predictor to also work with no regular exits Richard Guenther
@ 2011-06-09 14:06 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-06-09 14:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2043 bytes --]

On Thu, 9 Jun 2011, Richard Guenther wrote:

> 
> This is a complementary fix for the leslie3d problem.  For functions
> without a regular exit (for example one that exits with exit (0))
> we do not apply noreturn predictors.   The following patch notices
> that edges to noreturn calls are still unlikely if they have
> exactly one predecessor and is not fallthru.  In the leslie3d
> case this avoids predicting the edges to STOP but still correctly
> predicts the edges to the exceptional noreturn functions.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu, ok for trunk?

It regresses

FAIL: gcc.target/i386/umod-3.c scan-assembler-times divb 1

Richard.

> Thanks,
> Richard.
> 
> 2011-06-09  Richard Guenther  <rguenther@suse.de>
> 
> 	* predict.c (tree_bb_level_predictions): For functions with
> 	no regular exit still predict the edge to a block with a noreturn
> 	function as not taken if it is not a fallthru edge.
> 
> Index: gcc/predict.c
> ===================================================================
> --- gcc/predict.c	(revision 174746)
> +++ gcc/predict.c	(working copy)
> @@ -1613,10 +1613,18 @@ tree_bb_level_predictions (void)
>  
>  	  if (is_gimple_call (stmt))
>  	    {
> -	      if ((gimple_call_flags (stmt) & ECF_NORETURN)
> -	          && has_return_edges)
> -		predict_paths_leading_to (bb, PRED_NORETURN,
> -					  NOT_TAKEN);
> +	      if ((gimple_call_flags (stmt) & ECF_NORETURN))
> +		{
> +	          if (has_return_edges)
> +		    predict_paths_leading_to (bb, PRED_NORETURN,
> +					      NOT_TAKEN);
> +		  else if (single_pred_p (bb))
> +		    {
> +		      edge e = single_pred_edge (bb);
> +		      if (!(e->flags & EDGE_FALLTHRU))
> +			predict_edge_def (e, PRED_NORETURN, NOT_TAKEN);
> +		    }
> +		}
>  	      decl = gimple_call_fndecl (stmt);
>  	      if (decl
>  		  && lookup_attribute ("cold",
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-09 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 12:12 [PATCH] Fix noreturn predictor to also work with no regular exits Richard Guenther
2011-06-09 14:06 ` 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).