https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112626
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Naveen H.S <[email protected]>: https://gcc.gnu.org/g:59c8c4bbac46570ac36782172ed28569affe42c4 commit r17-4549-g59c8c4bbac46570ac36782172ed28569affe42c4 Author: Naveen <[email protected]> Date: Mon Sep 21 20:56:16 2026 -0700 tree-optimization: fold abs(x) comparisons with x [PR112626] 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. 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]>
