RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Sun, 16 Oct 2022 10:48:26 +0000 (12:48 +0200)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Fri, 18 Nov 2022 20:17:50 +0000 (21:17 +0100)
commit60d2bcc55bcc0991c0e58e97edf4a69e847e82c6
tree9a2f3f295f0e6e763fb4a3c36b068c302e8de1b6
parentbc6beecb4d64fcd82988f840fdad45a69d73c7bb
RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

Use Zbs when generating a sequence for
   "if ((a & twobits) == singlebit) ..."
that can be expressed as
   bexti + bexti + andn.

gcc/ChangeLog:

* config/riscv/bitmanip.md
(*branch<X:mode>_mask_twobits_equals_singlebit):
Handle "if ((a & T) == C)" using Zbs, when T has 2 bits set and C
has one of these tow bits set.
* config/riscv/predicates.md (const_twobits_not_arith_operand):
New predicate.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbs-if_then_else-01.c: New test.
gcc/config/riscv/bitmanip.md
gcc/config/riscv/predicates.md
gcc/testsuite/gcc.target/riscv/zbs-if_then_else-01.c [new file with mode: 0644]