https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125641
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:43356828d897ad96c5359e03f8f4aad2c283b81f commit r17-1683-g43356828d897ad96c5359e03f8f4aad2c283b81f Author: Kael Andrew Franco <[email protected]> Date: Thu Jun 18 21:00:44 2026 -0600 [PATCH] match: Optimize bit_ior/bit_and {bit_not} rshift to min/max [PR125641] Fold x | (x >> (TYPE_PRECISION (type) - 1)) to max (x, -1) Fold x | (~ (x >> (TYPE_PRECISION (type) - 1))) to min (x, -1) Fold x & (x >> (TYPE_PRECISION (type) - 1)) to min (x, 0) Fold x & (~ (x >> (TYPE_PRECISION (type) - 1))) to max (x, 0) Bootstrapped and tested on x86_64-pc-linux-gnu PR tree-optimization/125641 gcc/ChangeLog: PR tree-optimization/125641 * match.pd: Add bit_ior/bit_and {bit_not} rshift to min/max. gcc/testsuite/ChangeLog: PR tree-optimization/125641 * gcc.dg/pr125641.c: New test.
