[Bug tree-optimization/123123] `a != 0 ? 1 : a + 1` is not always optimized to 1
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 15 12:23:55 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123123
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |matz at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Possibly for all constants though, a != CST ? CST +- CST2 : a +- CST2. I'll
note this is conditional constant propagation of 'a' on the a == CST path
even for larger expressions than a +- CST2. IIRC there's that SSA-w/o-a-CFG
from Burg(?) where the two conditional forms ( :? vs. if()) can be handled
the same.
It might be interesting to have a constant/copy/folding (aka forwprop) pass
on such an intermediate representation.
More information about the Gcc-bugs
mailing list