https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36503
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <u...@gcc.gnu.org>: https://gcc.gnu.org/g:1ff69000b50e8ac184e925af71e794e7c3d5d2a6 commit r15-5635-g1ff69000b50e8ac184e925af71e794e7c3d5d2a6 Author: Uros Bizjak <ubiz...@gmail.com> Date: Sun Nov 24 22:00:18 2024 +0100 i386: x86 can use x >> -y for x >> 32-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 >> 32-y. This form is very common in bitstream readers, where it's used to read the top N bits from a word. The optimization converts: movl $32, %ecx subl %esi, %ecx sall %cl, %eax to: negl %ecx sall %cl, %eax PR target/36503 gcc/ChangeLog: * config/i386/i386.md (*ashl<mode>3_negcnt): New define_insn_and_split pattern. (*ashl<mode>3_negcnt_1): Ditto. (*<insn><mode>3_negcnt): Ditto. (*<insn><mode>3_negcnt_1): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/pr36503-1.c: New test. * gcc.target/i386/pr36503-2.c: New test.