https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107888
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > which means we fail to optimize a > b ? 1 : b as well, no? Yes that is correct. Even for max, "a >= b ? a : 6;" would need to be "reverted" 6 back to b. <bb 5> [local count: 1073741824]: if (ab_2(D) >= bb_3(D)) goto <bb 6>; [65.00%] else goto <bb 7>; [35.00%] <bb 6> [local count: 697932184]: <bb 7> [local count: 1073741824]: # c_1 = PHI <ab_2(D)(6), 6(5)> The min/max patterns inside match needs to handle CST if the ranges of the two operands overlap with one/two values. Even though this is a regression, I don't know if this shows up in real code and is a small optimization really so I would suspect a P4 for this really as it requires a bigger change that most likely won't be backported. I filed it as it was showing up while I was working on the patch for PR 101805 (which won't be submitted until GCC 14 anyways).