https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36503
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <[email protected]>: https://gcc.gnu.org/g:b20e68022a3f49010028dc01dab570c68071e3db commit r16-7123-gb20e68022a3f49010028dc01dab570c68071e3db Author: Uros Bizjak <[email protected]> Date: Wed Jan 28 21:57:47 2026 +0100 i386: Use x >> ~y for x >> 31-y [PR36503] x86 targets mask 32-bit shifts with a 5-bit mask (and 64-bit with 6-bit mask), so they can use x >> ~y instead of x >> 31-y. The optimization converts: movl $31, %ecx subl %esi, %ecx sall %cl, %eax to: notl %ecx sall %cl, %eax PR target/36503 gcc/ChangeLog: * config/i386/i386.md (*<insn:any_shift><mode:SWI48>3_sub): Also allow operands[3] & (<mode_bitsize>-1) == (<mode_bitsize>-1) in insn condition. Emit NOT RTX instead of NEG RTX in this case. (*<insn:any_shift><mode:SWI48>3_sub_1): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/pr36503-5.c: New test. * gcc.target/i386/pr36503-6.c: New test.
