On Thu, 25 Nov 2021, Jan Hubicka wrote: > Hi, > this pach removes gimple_call_cahin checkin ref_maybe_used_by_call_p that > disables check for CONST functions. I suppose it was meant to allow consts > to read variables from the static chain but this is not what other places > do. The testcase: > > int > main() > { > int a =0; > __attribute__ ((noinline,const)) > int reta () > { > return a; > } > int val = reta(); > a=1; > return val+reta (); > } > > Gets optimized to single call of reta since at least gcc 4.1. > > LTO bootstrapped and regtested x86_64-linux all languages. OK?
I suppose at some point it broke. But yes, I agree, thus OK. Thanks, Richard. > * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Do not check > gimple_call_call when treating const functions. > > diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c > index cd6a0b2f67b..3c253e2843f 100644 > --- a/gcc/tree-ssa-alias.c > +++ b/gcc/tree-ssa-alias.c > @@ -2743,9 +2743,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, > bool tbaa_p) > unsigned i; > int flags = gimple_call_flags (call); > > - /* Const functions without a static chain do not implicitly use memory. */ > - if (!gimple_call_chain (call) > - && (flags & (ECF_CONST|ECF_NOVOPS))) > + if (flags & (ECF_CONST|ECF_NOVOPS)) > goto process_args; > > /* A call that is not without side-effects might involve volatile > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)