RISC-V: optimize '(a >= 0) ? b : 0' to srai + andn, if compiling for Zbb
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Thu, 22 Sep 2022 23:37:14 +0000 (01:37 +0200)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Sun, 13 Nov 2022 15:47:20 +0000 (16:47 +0100)
commit43435c7eb0ff60f02838674efd99df93852a92cc
treee2d0410750a24131f53df90d45047a871a7e1216
parent3bf46ea7bce58918ae8da1c936fe4c55456d2b6b
RISC-V: optimize '(a >= 0) ? b : 0' to srai + andn, if compiling for Zbb

If-conversion is turning '(a >= 0) ? b : 0' into a branchless sequence
not a5,a0
srai a5,a5,63
and a0,a1,a5
missing the opportunity to combine the NOT and AND into an ANDN.

This adds a define_split to help the combiner reassociate the NOT with
the AND.

gcc/ChangeLog:

* config/riscv/bitmanip.md: New define_split.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbb-srai-andn.c: New test.
gcc/config/riscv/bitmanip.md
gcc/testsuite/gcc.target/riscv/zbb-srai-andn.c [new file with mode: 0644]