Do not check gimple_call_chain in tree-ssa-alias
Jan Hubicka
hubicka@kam.mff.cuni.cz
Thu Nov 25 13:11:05 GMT 2021
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?
* 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
More information about the Gcc-patches
mailing list