https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103359
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com
--- Comment #7 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> So the important part is to eliminate the store to 'c' which GCC11 manages
> to do
> from EVRP while trunk fails at this task. The IL into EVRP is absoultely
> identical:
>
> <bb 2> :
> goto <bb 8>; [INV]
>
> <bb 8> :
> # h_10 = PHI <4(2), h_10(3), h_10(4), 1(7)>
> d.2_8 = d;
> if (d.2_8 != 0)
> goto <bb 3>; [INV]
>
> <bb 3> :
> if (h_10 != 0)
> goto <bb 4>; [INV]
>
> <bb 4> :
> e.0_1 = e;
> if (e.0_1 != 0)
> goto <bb 5>; [INV]
>
> <bb 5> :
> a.1_2 = a;
> _3 = (short int) a.1_2;
> _14 = a.1_2 & 1;
> _4 = (short int) _14;
> _5 = _4 | h_10;
> _6 = (int) _5;
> f.4_21 = (unsigned short) _5;
> _23 = f.4_21 * 3;
> _24 = (short int) _23;
> if (_5 == 0)
> goto <bb 6>; [INV]
> else
> goto <bb 7>; [INV]
>
> <bb 6> :
> c = 0;
In GCC11 we had this right before evrp:
_5 = _4 | h_10;
_6 = (int) _5;
f.4_21 = (unsigned short) _5;
_23 = f.4_21 * 3;
_24 = (short int) _23;
if (_5 == 0)
goto <bb 6>; [INV]
else
goto <bb 7>; [INV]
which evrp could fold:
Visiting conditional with predicate: if (_5 == 0)
With known ranges
_5: short int ~[0, 0]
Predicate evaluates to: 0
However, in trunk the IL is different:
_5 = _4 | h_10;
_6 = (int) _5;
f.4_21 = (unsigned short) _5;
_23 = f.4_21 * 3;
_24 = (short int) _23;
if (_24 == 0)
goto <bb 6>; [INV]
else
goto <bb 7>; [INV]
Where did the cast come from in trunk? Cause without the case, we should be
able to fold it.
For that matter, in trunk we have:
Folding statement: if (_24 == 0)
Visiting conditional with predicate: if (_24 == 0)
With known ranges
_24: short int VARYING
Predicate evaluates to: DON'T KNOW
gimple_simplified to if (_5 == 0)
Folded into: if (_5 == 0)
So gimple fold does get rid of the cast for us, and at that point ranger can
figure out the conditional:
[ranger dump]
if (_5 == 0)
goto <bb 6>; [INV]
else
goto <bb 7>; [INV]
...
...
_5 : short int [-INF, -1][1, +INF]
Presumably we're asking ranger before calling gimple fold, but the question is,
what was going on in GCC11 that the _24 => _5 substitution was done before
arriving in evrp.