https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106025
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- It looks like the pattern just exposes an existing issue. -fdbg-cnt=match:0-104 breaks while -fdbg-cnt=match:0-103 is OK but the MAX generation for this looks correct. Disabling VRP fixes it but avoids the MAX generation as we end up with if (_22 < _33) goto <bb 8>; [50.00%] else goto <bb 7>; [50.00%] <bb 7> [local count: 536870913]: _36 = (short int) _22; # RANGE [-32768, 32767] _38 = (int) _36; <bb 8> [local count: 1073741824]: # RANGE [-32768, 32767] # prephitmp_39 = PHI <_1(6), _38(7)> _22 is indeed small. We recognize ushortA < ushortB ? (int)ushortB : (int)ushortA as (int)MAX (ushortA, ushortB) Not sure what goes wrong here.