https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67962
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Mine, but for gcc 13. The main problem I see if two cmov might be slower
> than a branch on x86_64 processors.
Two cmov definitely, a min/max pair not.
Now, phiopt will turn
<bb 2> :
if (y_16(D) < x_17(D))
goto <bb 3>; [INV]
else
goto <bb 4>; [INV]
<bb 3> :
<bb 4> :
# x_14 = PHI <x_17(D)(2), y_16(D)(3)>
if (y_16(D) < x_17(D))
goto <bb 5>; [INV]
else
goto <bb 6>; [INV]
<bb 5> :
<bb 6> :
# y_15 = PHI <y_16(D)(2), x_17(D)(3)>
into the desired pair but fails for the equivalent
<bb 2> :
if (y_16(D) < x_17(D))
goto <bb 3>; [INV]
else
goto <bb 4>; [INV]
<bb 3> :
<bb 4> :
# x_14 = PHI <x_17(D)(2), y_16(D)(3)>
# y_15 = PHI <y_16(D)(2), x_17(D)(3)>
We do value-replacement for more than one PHI but not others, not exactly
sure why. We could dry-run convert all PHIs and only if that succeeds
and the condition goes away perform the transforms. Of course some
transforms might still not be profitable then.