[Bug tree-optimization/122996] Missed optimisation for branch folding with unsigned arithmetic wraparound
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 4 07:35:52 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122996
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Mital Ashok from comment #0)
> Because the function is equivalent to `return x + 1u;`. This optimisation is
> done for `return x == 0u ? 1u : x + 1u;`.
That is handled by:
/* ?: Value replacement. */
/* a == 0 ? b : b + a -> b + a */
(for op (plus bit_ior bit_xor)
(simplify
(cond (eq @0 integer_zerop) @1 (op:c@2 @1 @0))
@2))
More information about the Gcc-bugs
mailing list