https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119418
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2025-03-24
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The double-ternary is of course most interesting to solve, we
expand from
<bb 2> [local count: 1073741824]:
_2 = y;
_4 = x;
pretmp_9 = z;
if (_2 < _4)
goto <bb 3>; [50.00%]
else
goto <bb 4>; [50.00%]
<bb 3> [local count: 536870912]:
_8 = _2 > pretmp_9;
_7 = _8 ? pretmp_9 : _2;
goto <bb 5>; [100.00%]
<bb 4> [local count: 536870912]:
_6 = _4 > pretmp_9;
_5 = _6 ? pretmp_9 : _4;
<bb 5> [local count: 1073741824]:
# _3 = PHI <_7(3), _5(4)>
return _3;
and the main issue is that we do not resolve the redundant load from *c
by hoisting it before phiopt early but it takes until PRE and late PHIopt
which then does not fully recognize
<bb 2> [local count: 1073741824]:
_2 = y;
_4 = x;
pretmp_9 = z;
if (_2 < _4)
goto <bb 3>; [50.00%]
else
goto <bb 5>; [50.00%]
<bb 3> [local count: 536870912]:
if (_2 > pretmp_9)
goto <bb 4>; [50.00%]
else
goto <bb 7>; [50.00%]
<bb 4> [local count: 268435456]:
goto <bb 7>; [100.00%]
<bb 5> [local count: 536870912]:
if (_4 > pretmp_9)
goto <bb 6>; [50.00%]
else
goto <bb 7>; [50.00%]
<bb 6> [local count: 268435456]:
<bb 7> [local count: 1073741824]:
# _3 = PHI <_2(3), _4(5), pretmp_9(6), pretmp_9(4)>
return _3;
since the "nested" min/max recognition code does not recognize the
_8 = _2 > pretmp_9;
_7 = _8 ? pretmp_9 : _2;
form of min/max.