]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix PR 108874: aarch64 code regression with shift and ands
authorAndrew Pinski <apinski@marvell.com>
Fri, 10 Mar 2023 00:53:39 +0000 (00:53 +0000)
committerAndrew Pinski <apinski@marvell.com>
Fri, 10 Mar 2023 17:51:54 +0000 (17:51 +0000)
commitfcbc5c190c40b51c82f827830ce403c07d628960
tree89071f26d2ff6e06cbca307e38ad9ad383c26088
parentf8332e52a498df480f72303de32ad0751ad899fe
Fix PR 108874: aarch64 code regression with shift and ands

After r6-2044-g98e30e515f184b, code like "((x & 0xff00ff00U) >> 8)"
would be optimized like (x >> 8) & 0xff00ffU which is normally better
except on aarch64, the shift right could be combined with another
operation in some cases. So we need to add a few define_splits
to the aarch64 backends that match "((x >> shift) & CST0) OP Y"
and splits it to:
TMP = X & CST1
(TMP >> shift) OP Y

Note this also gets us to matching rev16 back too so I added a
testcase to make sure we don't lose that matching any more.
Note when the generic patch to recognize those as bswap ROT 16,
we might regress again and need to add a few more patterns to
the aarch64 backend but will deal with that once that happens.

Committed as approved after a bootstrapp/test on aarch64-linux-gnu with no regressions.

gcc/ChangeLog:

* config/aarch64/aarch64.md: Add a new define_split
to help combine.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/rev16_2.c: New test.
* gcc.target/aarch64/shift_and_operator-1.c: New test.
gcc/config/aarch64/aarch64.md
gcc/testsuite/gcc.target/aarch64/rev16_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/shift_and_operator-1.c [new file with mode: 0644]