]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Handle ZERO_EXTEND like SIGN_EXTEND in bsr patterns [PR120434]
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Jun 2025 18:07:06 +0000 (20:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Jun 2025 18:07:39 +0000 (20:07 +0200)
commit54da199f28da07166a44eae7d53acb9e3abe1306
tree1cc6a401f4858b0dfa39faf75d26fa8c440682a6
parent8154fc95f097a146f9c80edcaafb2baff73065b5
i386: Handle ZERO_EXTEND like SIGN_EXTEND in bsr patterns [PR120434]

The just posted second PR120434 patch causes
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler \\\\m(leaq|addq|incq)\\\\M
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\mmovl\\\\M+
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\msubq\\\\M
+FAIL: gcc.target/i386/pr78103-3.c scan-assembler-not \\\\mxor[lq]\\\\M
While the patch generally improves code generation by often using
ZERO_EXTEND instead of SIGN_EXTEND, where the former is often for free
on x86_64 while the latter requires an extra instruction or larger
instruction than one with just zero extend, the PR78103 combine patterns
and splitters were written only with SIGN_EXTEND in mind.  As CLZ is UB
on 0 and otherwise returns just [0,63] and is xored with 63, ZERO_EXTEND
does the same thing there as SIGN_EXTEND.

2025-06-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120434
* config/i386/i386.md (*bsr_rex64_2): Rename to ...
(*bsr_rex64<u>_2): ... this.  Use any_extend instead of sign_extend.
(*bsr_2): Rename to ...
(*bsr<u>_2): ... this.  Use any_extend instead of sign_extend.
(bsr splitters after those): Use any_extend instead of sign_extend.
gcc/config/i386/i386.md