public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Add rotate immediate regression test
@ 2023-08-16 23:14 Patrick O'Neill
  2023-08-16 23:18 ` Andrew Pinski
  2023-08-17  1:17 ` [PATCH v2] RISCV: " Patrick O'Neill
  0 siblings, 2 replies; 6+ messages in thread
From: Patrick O'Neill @ 2023-08-16 23:14 UTC (permalink / raw)
  To: gcc-patches
  Cc: wangfeng, jeffreyalaw, gnu-toolchain, palmer, charlie,
	Patrick O'Neill

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-04.c: Add half-register rotation
	cases.
	* gcc.target/riscv/zbb-rol-ror-05.c: Add half-register rotation
	case.

Co-authored-by: Charlie Jenkins <charlie@rivosinc.com>
Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
---
Trunk optimized these added testcases correctly.
GCC 13.2 and earlier do not optimize these cases correctly.

Expands on testcases added in:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c;h=0ccf520d349a82dafca0deb3d307a1080e8589a0
---
 .../gcc.target/riscv/zbb-rol-ror-04.c         | 20 +++++++++++++++++++
 .../gcc.target/riscv/zbb-rol-ror-05.c         | 10 ++++++++++
 2 files changed, 30 insertions(+)

diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
index 7ef4c29dd5b..dcd7be874ab 100644
--- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
+++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
@@ -51,3 +51,23 @@ unsigned int foo5(unsigned int rs1, unsigned int rs2)
 {
     return (rs1 >> rs2) | (rs1 << (32 - rs2));
 }
+
+/*
+**foo6:
+**	rori	a0,a0,32
+**	ret
+*/
+unsigned long foo6(unsigned long rotate)
+{
+    return (rotate << 32) | (rotate >> 32);
+}
+
+/*
+**foo7:
+**	roriw	a0,a0,16
+**	ret
+*/
+unsigned int foo7(unsigned int rotate)
+{
+    return (rotate << 16) | (rotate >> 16);
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
index 2108ccc3e77..5ae1d4a92d9 100644
--- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
+++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
@@ -23,3 +23,13 @@ unsigned int foo2(unsigned int rs1)
 {
     return (rs1 << 10) | (rs1 >> 22);
 }
+
+/*
+**foo3:
+**	rori	a0,a0,16
+**	ret
+*/
+unsigned int foo3(unsigned int rs1)
+{
+    return (rs1 << 16) | (rs1 >> 16);
+}
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-17 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-16 23:14 [PATCH] RISC-V: Add rotate immediate regression test Patrick O'Neill
2023-08-16 23:18 ` Andrew Pinski
2023-08-17  1:17 ` [PATCH v2] RISCV: " Patrick O'Neill
2023-08-17  4:36   ` Jeff Law
2023-08-17 17:10     ` [Committed] " Patrick O'Neill
2023-08-17 17:40       ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).