]> gcc.gnu.org Git - gcc.git/commitdiff
RISCV: Add rotate immediate regression test
authorPatrick O'Neill <patrick@rivosinc.com>
Wed, 16 Aug 2023 18:55:41 +0000 (11:55 -0700)
committerPatrick O'Neill <patrick@rivosinc.com>
Thu, 17 Aug 2023 17:08:58 +0000 (10:08 -0700)
This adds new regression tests to ensure half-register rotations are
correctly optimized into rori instructions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbb-rol-ror-08.c: New test.
* gcc.target/riscv/zbb-rol-ror-09.c: New test.

Co-authored-by: Charlie Jenkins <charlie@rivosinc.com>
Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c
new file mode 100644 (file)
index 0000000..30696f3
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -fno-lto -O2" } */
+/* { dg-skip-if "" { *-*-* } { "-g" } } */
+/* { dg-final { check-function-bodies "**" "" } } */
+/* { dg-final { scan-assembler-not "and" } } */
+
+/*
+**foo1:
+**     rori    a0,a0,32
+**     ret
+*/
+unsigned long foo1(unsigned long rotate)
+{
+    return (rotate << 32) | (rotate >> 32);
+}
+
+/*
+**foo2:
+**     roriw   a0,a0,16
+**     ret
+*/
+unsigned int foo2(unsigned int rotate)
+{
+    return (rotate << 16) | (rotate >> 16);
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c
new file mode 100644 (file)
index 0000000..a305455
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gc_zbb -mabi=ilp32 -fno-lto -O2" } */
+/* { dg-skip-if "" { *-*-* } { "-g" } } */
+/* { dg-final { check-function-bodies "**" "" } } */
+/* { dg-final { scan-assembler-not "and" } } */
+
+/*
+**foo1:
+**     rori    a0,a0,16
+**     ret
+*/
+unsigned int foo1(unsigned int rs1)
+{
+    return (rs1 << 16) | (rs1 >> 16);
+}
This page took 0.07187 seconds and 5 git commands to generate.