This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Improve unrolled size estimates
> On Mon, 11 May 2009, Jan Hubicka wrote:
>
> > >
> > > That is, I still dislike that you only handle constant index loads
> > > from strings. How does the benchmark numbers look like if you
> > > remove that?
> >
> > I handle both STRING_CST and DECL with CONSTANT flag and DECL_INITIAL.
>
> Oh, indeed you do. Ok, change
>
> + if ((DECL_P (base) && TREE_CONSTANT (base) && DECL_INITIAL (base))
> + || TREE_CODE (base) == STRING_CST)
>
> to what get_symbol_constant_value checks, namely
>
> + if ((DECL_P (base)
> && TREE_READONLY (base)
> && DECL_INITIAL (base)
> && targetm.binds_local_p (base))
> + || CONSTANT_CLASS_P (base))
I ended up with test:
if ((DECL_P (base)
&& TREE_STATIC (base)
&& TREE_READONLY (sym)
&& (DECL_INITIAL (base)
|| (!DECL_EXTERNAL (base)
&& targetm.binds_local_p (base))))
|| CONSTANT_CLASS_P (base))
I.e. either we know what the variable is initialized to, or it has
implicit 0 initializer when it can't be initialized from other unit.
This is what get_symbol_constant_value does too.
Thanks!
Honza