Patchwork [RFC] Context sensitive inline analysis

login
register
mail settings
Submitter Jan Hubicka
Date Sept. 27, 2011, 2:46 p.m.
Message ID <20110927144617.GF21364@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/116615/
State New
Headers show

Comments

Jan Hubicka - Sept. 27, 2011, 2:46 p.m.
> > This caused:
> >
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49179
> >
> >
> 
> This also caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49091
> 

Hi,
the problem is sign overflow in time computation. Time should be capped by MAX_TIME
and we compute MAX_TIME * INLINE_SIZE_SCALE * 2. This happens to be >2^31 & <2^32
so we overflow here because of use of signed arithmetics.

Hopefully the following is enough.  The floating point arithmetics would make things easier
since loop structure can scale times up a lot and their relative comparsions matters for
benefit computation.  Not sure if switching it to our software floats is the coolest
idea however.

Will commit it after testing on x86_64-linux
Richard Sandiford - Sept. 28, 2011, 10:54 a.m.
Jan Hubicka <hubicka@ucw.cz> writes:
> the problem is sign overflow in time computation. Time should be
> capped by MAX_TIME and we compute MAX_TIME * INLINE_SIZE_SCALE *
> 2. This happens to be >2^31 & <2^32 so we overflow here because of use
> of signed arithmetics.
>
> Index: ipa-inline-analysis.c
> ===================================================================
> --- ipa-inline-analysis.c	(revision 179266)
> +++ ipa-inline-analysis.c	(working copy)
> @@ -92,7 +92,7 @@ along with GCC; see the file COPYING3.
>  /* Estimate runtime of function can easilly run into huge numbers with many
>     nested loops.  Be sure we can compute time * INLINE_SIZE_SCALE in integer.
>     For anything larger we use gcov_type.  */
> -#define MAX_TIME 1000000
> +#define MAX_TIME 500000
>  
>  /* Number of bits in integer, but we really want to be stable across different
>     hosts.  */

Could you update the comment too?  ("time * INLINE_SIZE_SCALE * 2")

Richard

Patch

Index: ipa-inline-analysis.c
===================================================================
--- ipa-inline-analysis.c	(revision 179266)
+++ ipa-inline-analysis.c	(working copy)
@@ -92,7 +92,7 @@  along with GCC; see the file COPYING3.
 /* Estimate runtime of function can easilly run into huge numbers with many
    nested loops.  Be sure we can compute time * INLINE_SIZE_SCALE in integer.
    For anything larger we use gcov_type.  */
-#define MAX_TIME 1000000
+#define MAX_TIME 500000
 
 /* Number of bits in integer, but we really want to be stable across different
    hosts.  */