On 9/21/26 7:30 AM, Naveen wrote:
From: Naveen <[email protected]>

The patterns account for both undefined-overflow and wrapping-overflow
semantics. Comparisons whose result is independent of the value of
`x` are folded to constants while the remaining cases are reduced to
sign tests. With wrapping overflow, the `INT_MIN` case is handled
explicitly using unsigned comparisons.

Handle comparisons between unsigned conversions of `abs (x)` and `x`.
These transformations are applied only when the conversions have
matching unsigned types and the same precision. Sign-test forms are
restricted to undefined-overflow semantics; wrapping-overflow variants
are left for future work.

Bootstrapped and regtested on x86_64 and aarch64. No new regressions.

gcc ChangeLog:
        PR tree-optimization/112626
        * match.pd: Fold comparisons between abs (x) and x including
        unsigned conversions of both operands.

gcc/testsuite/ChangeLog:
        PR tree-optimization/112626
        * gcc.dg/tree-ssa/pr112626.c: New test.
        * gcc.dg/tree-ssa/pr112626-wrap.c: New test.

Signed-off-by: Naveen <[email protected]>
OK.  Thanks!

jeff

Reply via email to