https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109637
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-04-26
Component|middle-end |tree-optimization
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
# RANGE [irange] unsigned char [0, 3] NONZERO 0x3
_6 = (unsigned charD.30) _1;
# RANGE [irange] unsigned char [0, 2][+INF, +INF]
_2 = _6 + 255;
if (_2 <= 2)
VRP Should have changed _2 <= 2 to just _2 != 255 which then gets folded into
_6 != 0 which then will get folded into _1 != 0
and then phiopt could also have sunk the cast:
if (_2 <= 2)
goto <bb 3>; [50.00%]
else
goto <bb 4>; [50.00%]
<bb 3> [local count: 536870913]:
<L7>:
_9 = (int) _1;
<bb 4> [local count: 1073741824]:
# _3 = PHI <0(2), _9(3)>
Which then would get simplified into just:
_3 = (int)_1;
So there are a few things that needed to be done here ...