* Fix ipa-modref pure/const discovery
@ 2021-11-12 13:03 Jan Hubicka
0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-11-12 13:03 UTC (permalink / raw)
To: gcc-patches
Hi,
this patch fixes bug I introduced while breaking up the bigger change.
We currently can not use pure/const to discover looping pures&const
since lack of global memory writes/stores does not imply we can CSE on
the function. THis is witnessed by testsuite doing volatile asm
or also can happen if i.e. function returns result of malloc.
I have followup patch to add the analysis, but will first look into
current ICE of ltobootstrap.
Bootstrapped/regtested x86_64-linux, comitted.
PR ipa/103200
* ipa-modref.c (analyze_function, modref_propagate_in_scc): Do
not mark pure/const function if there are side-effects.
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 72006251f29..44b3427a202 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -2790,7 +2790,8 @@ analyze_function (function *f, bool ipa)
if (!ipa && flag_ipa_pure_const)
{
- if (!summary->stores->every_base && !summary->stores->bases)
+ if (!summary->stores->every_base && !summary->stores->bases
+ && !summary->side_effects)
{
if (!summary->loads->every_base && !summary->loads->bases)
fixup_cfg = ipa_make_function_const
@@ -4380,7 +4381,8 @@ modref_propagate_in_scc (cgraph_node *component_node)
modref_summary_lto *summary_lto = summaries_lto
? summaries_lto->get (cur)
: NULL;
- if (summary && !summary->stores->every_base && !summary->stores->bases)
+ if (summary && !summary->stores->every_base && !summary->stores->bases
+ && !summary->side_effects)
{
if (!summary->loads->every_base && !summary->loads->bases)
pureconst |= ipa_make_function_const
@@ -4390,7 +4392,7 @@ modref_propagate_in_scc (cgraph_node *component_node)
(cur, summary->side_effects, false);
}
if (summary_lto && !summary_lto->stores->every_base
- && !summary_lto->stores->bases)
+ && !summary_lto->stores->bases && !summary_lto->side_effects)
{
if (!summary_lto->loads->every_base && !summary_lto->loads->bases)
pureconst |= ipa_make_function_const
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-12 13:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 13:03 Fix ipa-modref pure/const discovery Jan Hubicka
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).