https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110487
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- /* Optimize # x_5 in range [cst1, cst2] where cst2 = cst1 + 1 x_5 ? cstN ? cst4 : cst3 # op is == or != and N is 1 or 2 to r_6 = x_5 + (min (cst3, cst4) - cst1) or r_6 = (min (cst3, cst4) + cst1) - x_5 depending on op, N and which of cst3 and cst4 is smaller. This was originally done by two_value_replacement in phiopt (PR 88676). */ is going to have the same issue I think.