]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RISC-V] Add testcase for shifted truthvalue
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Sat, 8 Nov 2025 16:28:07 +0000 (09:28 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 8 Nov 2025 16:30:17 +0000 (09:30 -0700)
I was doing some cleanup on our internal tree and noticed a pattern that I
didn't think was actually useful in practice.  Thankfully the internal commit
included a testcase clearly targeting that pattern.

I'm upstreaming the testcase, but not the unnecessary pattern.

gcc/testsuite
* gcc.target/riscv/snez.c: New test.

gcc/testsuite/gcc.target/riscv/snez.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.target/riscv/snez.c b/gcc/testsuite/gcc.target/riscv/snez.c
new file mode 100644 (file)
index 0000000..e5a7fad
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-O1" } } */
+
+int f (long long a)
+{
+  return (a != 2) << 1;
+}
+
+/* { dg-final { scan-assembler-times "slli\t" 1 } } */
+/* { dg-final { scan-assembler-not "srli\t" } } */
+/* { dg-final { scan-assembler-times "snez\t" 1 } } */
+/* { dg-final { scan-assembler-not "sext.w\t" } } */
+