]> git.ipfire.org Git - thirdparty/gcc.git/commit
Avoid andn and generate shorter not;and with -Oz on x86.
authorRoger Sayle <roger@nextmovesoftware.com>
Wed, 18 May 2022 15:13:17 +0000 (16:13 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Wed, 18 May 2022 15:18:22 +0000 (16:18 +0100)
commit30405ccc143bb4b63476a329800244826a88faf3
tree6638507ed0d6c55379c90160bf00736a44f686ba
parent60fdce11dc9e5ddf671b07a3fc6ed70476860b22
Avoid andn and generate shorter not;and with -Oz on x86.

The x86 instruction encoding for SImode andn is longer than the
equivalent notl/andl sequence when the source for the not operand
is the same register as the destination.  This patch adds post_reload
splitters to i386.md to avoid "-mbmi" (which enables andn) increasing
code size with "-Oz".

One minor subtlety with this patch is that the splitter for
*andn_si_ccno swaps the order of operands (match_dup 2 and match_dup 3)
as memory operands need to appear first in *test<mode>_1 patterns.

2022-05-18  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.md (define_split):  Split *andsi_1
and *andn_si_ccno after reload with -Oz.

gcc/testsuite/ChangeLog
* gcc.target/i386/bmi-andn-3.c: New test case.
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/bmi-andn-3.c [new file with mode: 0644]