https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85636
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-05-04
CC| |rguenth at gcc dot gnu.org
Version|unknown |9.0
Summary|Tree if-conversion inserts |Tree if-conversion inserts
|bogus loads |redundant loads
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think this is just a missed optimization from the fact that we have two
conditional stores to a[i] before if-conversion. Those get introduced
by jump-threading which duplicates them when threading the v == 20
controlled paths through the dominated v != 20 condition.
Now - what if-conversion could recognize is that we are dealing with
the same store on each path and avoid the RMW transform it does.
Currently it translates
if (v_12 == 20)
a[i] = x;
else
a[i] = y;
as
a[i] = v_12 == 20 ? x : a[i];
a[i] = v_12 == 20 ? a[i] : y;
somehow "merging" those conditional stores where that is valid is missing.