https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126085
Drea Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Actually this can be generalized.
if a has range [CST,CST+1] then `a + CST2`
can just be `a == CST+1 ? CST2+CST+1 : CST2+CST`
Though I am pretty sure `a+CST` is always a better form.
Actually we have the reverse already:
/* 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). */