public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix leslie3d performance regression with -flto/-fwhole-program
  2011-06-09 12:37 [PATCH] Fix leslie3d performance regression with -flto/-fwhole-program Tobias Burnus
@ 2011-06-09 12:37 ` Richard Guenther
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2011-06-09 12:37 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran

On Thu, 9 Jun 2011, Tobias Burnus wrote:

> Richard Guenther wrote:
> > leslie3d terminates itself with STOP which translates to a noreturn
> > function.  This causes our edge hot/cold prediction machinery to not
> > apply any predictions based on paths to noreturn functions
> 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu.
> > Ok for trunk?
> 
> OK. Thanks for tracing this down and for the patch.
> I think it is rather obvious.
> 
> (I only wonder a bit why that's a regression.)

It's a "regression" in that, leslie3d runs slower with -fwhole-program
than without.

Richard.

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

* Re: [PATCH] Fix leslie3d performance regression with -flto/-fwhole-program
@ 2011-06-09 12:37 Tobias Burnus
  2011-06-09 12:37 ` Richard Guenther
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2011-06-09 12:37 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches, fortran

Richard Guenther wrote:
> leslie3d terminates itself with STOP which translates to a noreturn
> function.  This causes our edge hot/cold prediction machinery to not
> apply any predictions based on paths to noreturn functions

> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> Ok for trunk?

OK. Thanks for tracing this down and for the patch.
I think it is rather obvious.

(I only wonder a bit why that's a regression.)

Tobias

PS: Cross ref for gfortran readers: This patch has a sister middle-end
patch at http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00723.html

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

* [PATCH] Fix leslie3d performance regression with -flto/-fwhole-program
@ 2011-06-09 11:56 Richard Guenther
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2011-06-09 11:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Jan Hubicka


leslie3d terminates itself with STOP which translates to a noreturn
function.  This causes our edge hot/cold prediction machinery to not
apply any predictions based on paths to noreturn functions (because
there is no path that does not lead to a noreturn function).  This
in turn makes us predict the error path for ALLOCATE statements
as likely, leading to the tail of the function becoming cold.
This is because the error path is guarded by a if (ptr != 0) which
is predicted as likely - that is quite unusual, so we should
mark those tests as unlikely.  Done with the following patch.

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

Ok for trunk?

Thanks,
Richard.

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

	* trans.c (gfc_allocate_array_with_status): Mark error path
	as unlikely.

Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c	(revision 174746)
+++ gcc/fortran/trans.c	(working copy)
@@ -697,8 +697,9 @@ gfc_allocate_array_with_status (stmtbloc
 
   /* Create a variable to hold the result.  */
   res = gfc_create_var (type, NULL);
-  null_mem = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, mem,
-			      build_int_cst (type, 0));
+  null_mem = gfc_unlikely (fold_build2_loc (input_location, NE_EXPR,
+					    boolean_type_node, mem,
+					    build_int_cst (type, 0)));
 
   /* If mem is NULL, we call gfc_allocate_with_status.  */
   gfc_start_block (&alloc_block);
@@ -751,7 +752,7 @@ gfc_allocate_array_with_status (stmtbloc
     }
 
   tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, null_mem,
-			 alloc, error);
+			 error, alloc);
   gfc_add_expr_to_block (block, tmp);
 
   return res;

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 12:37 [PATCH] Fix leslie3d performance regression with -flto/-fwhole-program Tobias Burnus
2011-06-09 12:37 ` Richard Guenther
  -- strict thread matches above, loose matches on Subject: below --
2011-06-09 11:56 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).