https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126087
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:f8eb22d8408b25f337fad514aa8f47fe24f051d9 commit r17-2487-gf8eb22d8408b25f337fad514aa8f47fe24f051d9 Author: Neal Patalay <[email protected]> Date: Fri Jul 17 04:02:39 2026 -0700 match: Simplify sign tests for MIN and BIT_IOR [PR126087] When `b` is known to be non-negative, the sign of both `MIN (a, b)` and `a | b` depends only on the sign of `a`. Add patterns to match.pd to optimize `MIN (a, b) cmp 0` and `(a | b) cmp 0` into `a cmp 0`, where `cmp` is `<` or `>=`. Currently, `(a | b) cmp 0` is optimized at the RTL level for some targets, but simplifying earlier is preferable. PR tree-optimization/126087 gcc/ChangeLog: * match.pd: Simplify MIN and BIT_IOR compared to 0 when one operand is non-negative. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr126087.c: New test. Signed-off-by: Neal Patalay <[email protected]>
