aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Lu <ewlu@rivosinc.com>2025-09-08 10:48:45 -0700
committerEdwin Lu <ewlu@rivosinc.com>2025-09-12 10:34:13 -0700
commitd0c08415310d1daecb28f8fbfeef3d7f18b21d56 (patch)
treeb76fa55bf0dd5b81be12ef6c47bb157ec63dca78
parentbf257c548cb71dea6da9c11d154f629c65dc2275 (diff)
downloadgcc-d0c08415310d1daecb28f8fbfeef3d7f18b21d56.zip
gcc-d0c08415310d1daecb28f8fbfeef3d7f18b21d56.tar.gz
gcc-d0c08415310d1daecb28f8fbfeef3d7f18b21d56.tar.bz2
RISC-V: Support vnclip idiom testcase [PR120378]
This patch contains testcases for PR120378 after the change made to support the vnclipu variant of the SAT_TRUNC pattern. PR target/120378 gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr120378-1.c: New test. * gcc.target/riscv/rvv/autovec/pr120378-2.c: New test. * gcc.target/riscv/rvv/autovec/pr120378-3.c: New test. * gcc.target/riscv/rvv/autovec/pr120378-4.c: New test. Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
-rw-r--r--gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-1.c21
-rw-r--r--gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-2.c21
-rw-r--r--gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-3.c21
-rw-r--r--gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-4.c21
4 files changed, 84 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-1.c
new file mode 100644
index 0000000..500028e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+#include <stdint.h>
+
+inline uint8_t
+clip_uint8 (int x)
+{
+ return x & (~255) ? (-x) >> 31 : x;
+}
+
+void __attribute__ ((noipa))
+clip_loop (uint8_t *res, int *x, int w)
+{
+ for (int i = 0; i < w; i++)
+ res[i] = clip_uint8 (x[i]);
+}
+
+/* { dg-final { scan-tree-dump-times ".SAT_TRUNC " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "MAX_EXPR " 1 "optimized" } } */
+/* { dg-final { scan-assembler-times {vnclipu\.wi} 2 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-2.c
new file mode 100644
index 0000000..9a880e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-2.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+#include <stdint.h>
+
+inline uint16_t
+clip_uint16 (int x)
+{
+ return x & (~65535) ? (-x) >> 31 : x;
+}
+
+void __attribute__ ((noipa))
+clip_loop (uint16_t *res, int *x, int w)
+{
+ for (int i = 0; i < w; i++)
+ res[i] = clip_uint16 (x[i]);
+}
+
+/* { dg-final { scan-tree-dump-times ".SAT_TRUNC " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "MAX_EXPR " 1 "optimized" } } */
+/* { dg-final { scan-assembler-times {vnclipu\.wi} 1 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-3.c
new file mode 100644
index 0000000..d6b2ddd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-3.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+#include <stdint.h>
+
+inline uint8_t
+clip_uint8 (int64_t x)
+{
+ return x & (~255) ? (-x) >> 63 : x;
+}
+
+void __attribute__ ((noipa))
+clip_loop (uint8_t *res, int64_t *x, int w)
+{
+ for (int i = 0; i < w; i++)
+ res[i] = clip_uint8 (x[i]);
+}
+
+/* { dg-final { scan-tree-dump-times ".SAT_TRUNC " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "MAX_EXPR " 1 "optimized" } } */
+/* { dg-final { scan-assembler-times {vnclipu\.wi} 3 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-4.c
new file mode 100644
index 0000000..4657e52
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr120378-4.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+#include <stdint.h>
+
+inline uint16_t
+clip_uint16 (int64_t x)
+{
+ return x & (~65535) ? (-x) >> 63 : x;
+}
+
+void __attribute__ ((noipa))
+clip_loop (uint16_t *res, int64_t *x, int w)
+{
+ for (int i = 0; i < w; i++)
+ res[i] = clip_uint16 (x[i]);
+}
+
+/* { dg-final { scan-tree-dump-times ".SAT_TRUNC " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "MAX_EXPR " 1 "optimized" } } */
+/* { dg-final { scan-assembler-times {vnclipu\.wi} 2 } } */