]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: x86 can use x >> y for x >> 32+y [PR36503]
authorUros Bizjak <ubizjak@gmail.com>
Wed, 27 Nov 2024 19:45:25 +0000 (20:45 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 27 Nov 2024 19:46:46 +0000 (20:46 +0100)
commit093584abb854559393e36cd4cdcf9dc4862dd046
tree9a168e1fa9991bdb1bd24d59adaf352a7ca290cd
parentbca515ff1893fe4ca1a9042364af3c43f93a397c
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.

The optimization converts:

leal    32(%rsi), %ecx
sall    %cl, %eax

to:
sall    %cl, %eax

PR target/36503

gcc/ChangeLog:

* config/i386/i386.md (*ashl<mode>3_add):
New define_insn_and_split pattern.
(*ashl<mode>3_add_1): Ditto.
(*<insn><mode>3_add): Ditto.
(*<insn><mode>3_add_1): Ditto.
(*ashl<mode>3_sub): Rename from *ashl<mode>3_negcnt.
(*ashl<mode>3_sub_1): Rename from *ashl<mode>3_negcnt_1.
(*<insn><mode>3_sub): Rename from *<insn><mode>3_negcnt.
(*<insn><mode>3_sub_1): Rename from *<insn><mode>3_negcnt_1.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr36503-3.c: New test.
* gcc.target/i386/pr36503-4.c: New test.
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr36503-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr36503-4.c [new file with mode: 0644]