The splitter for a one-bit left rotation with the incoming bit inverted
emits rori and xori.  Enable it for Zbkb, which also provides rori.

gcc/ChangeLog:

        * config/riscv/riscv.md: Enable the rotate-and-invert splitter
        for Zbkb.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/pr121778-3.c: New test.
---
 gcc/config/riscv/riscv.md                   |  2 +-
 gcc/testsuite/gcc.target/riscv/pr121778-3.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/pr121778-3.c

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 6588a1c4ffa..22579ad1ef4 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -4970,7 +4970,7 @@
        (ashift:X (match_operand:X 1 "register_operand")
                  (const_int 1))
                (ge:X (match_dup 1) (const_int 0))))]
-  "TARGET_ZBB"
+  "TARGET_ZBB || TARGET_ZBKB"
   [(set (match_dup 0)
        (rotatert:X (match_dup 1) (match_operand 2 "const_int_operand")))
    (set (match_dup 0)
diff --git a/gcc/testsuite/gcc.target/riscv/pr121778-3.c 
b/gcc/testsuite/gcc.target/riscv/pr121778-3.c
new file mode 100644
index 00000000000..de407a57a00
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr121778-3.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gc_zbkb -mabi=lp64" { target rv64 } } */
+/* { dg-options "-O2 -march=rv32gc_zbkb -mabi=ilp32" { target rv32 } } */
+
+unsigned long
+foo (unsigned long x)
+{
+  return (x << 1) | ((long) x >= 0);
+}
+
+/* { dg-final { scan-assembler {\mrori\M} } } */
+/* { dg-final { scan-assembler {\mxori\M} } } */

Reply via email to