aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPan Li <pan2.li@intel.com>2025-08-01 10:46:58 +0800
committerPan Li <pan2.li@intel.com>2025-08-11 21:10:09 +0800
commit86abacb710b559a022ac61ef955457f0efe79a0a (patch)
treea7062f4ebf9f510a4d84c0372be782c7136b66eb /gcc
parent7d2daedde2a4ec620735d84610b05203a9cc2606 (diff)
downloadgcc-86abacb710b559a022ac61ef955457f0efe79a0a.zip
gcc-86abacb710b559a022ac61ef955457f0efe79a0a.tar.gz
gcc-86abacb710b559a022ac61ef955457f0efe79a0a.tar.bz2
RISC-V: Add testcase for scalar unsigned SAT_MUL form 2
Add run and asm check test cases for scalar unsigned SAT_MUL form 2. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat/sat_u_mul-3-u16.c: New test. * gcc.target/riscv/sat/sat_u_mul-3-u32.c: New test. * gcc.target/riscv/sat/sat_u_mul-3-u64.c: New test. * gcc.target/riscv/sat/sat_u_mul-3-u8.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-3-u16.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-3-u32.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-3-u64.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-3-u8.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_arith.h15
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u16.c11
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u32.c11
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u64.c11
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u8.c11
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u16.c15
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u32.c15
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u64.c15
-rw-r--r--gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u8.c15
9 files changed, 119 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
index e40902a..d1dfd12 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
@@ -693,4 +693,19 @@ sat_u_mul_##NT##_from_##WT##_fmt_1 (NT a, NT b) \
sat_u_mul_##NT##_from_##WT##_fmt_1 (a, b)
#define RUN_SAT_U_MUL_FMT_1_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_1(NT, WT, a, b)
+#define DEF_SAT_U_MUL_FMT_2(T) \
+T __attribute__((noinline)) \
+sat_u_mul_##T##_fmt_2 (T a, T b) \
+{ \
+ T result; \
+ if (__builtin_mul_overflow(a, b, &result)) \
+ return -1; \
+ else \
+ return result; \
+}
+
+#define DEF_SAT_U_MUL_FMT_2_WRAP(T) DEF_SAT_U_MUL_FMT_2(T)
+#define RUN_SAT_U_MUL_FMT_2(T, a, b) sat_u_mul_##T##_fmt_2 (a, b)
+#define RUN_SAT_U_MUL_FMT_2_WRAP(T, a, b) RUN_SAT_U_MUL_FMT_2(T, a, b)
+
#endif
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u16.c
new file mode 100644
index 0000000..714a7f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u16.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define T uint16_t
+
+DEF_SAT_U_MUL_FMT_2_WRAP(T)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
+/* { dg-final { scan-assembler-not "\.L\[0-9\]+" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u32.c
new file mode 100644
index 0000000..bd6eafc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u32.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define T uint32_t
+
+DEF_SAT_U_MUL_FMT_2_WRAP(T)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
+/* { dg-final { scan-assembler-not "\.L\[0-9\]+" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u64.c
new file mode 100644
index 0000000..c96687f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u64.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define T uint64_t
+
+DEF_SAT_U_MUL_FMT_2_WRAP(T)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
+/* { dg-final { scan-assembler-not "\.L\[0-9\]+" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u8.c
new file mode 100644
index 0000000..a92447f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-3-u8.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define T uint8_t
+
+DEF_SAT_U_MUL_FMT_2_WRAP(T)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
+/* { dg-final { scan-assembler-not "\.L\[0-9\]+" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u16.c
new file mode 100644
index 0000000..73f619b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u16.c
@@ -0,0 +1,15 @@
+/* { dg-do run { target { rv32 || rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint16_t
+#define NAME usmul
+#define DATA TEST_BINARY_DATA_WRAP(NT, NAME)
+#define T TEST_BINARY_STRUCT_DECL_WRAP(NT, NAME)
+#define RUN_BINARY(x, y) RUN_SAT_U_MUL_FMT_2_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_2_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u32.c
new file mode 100644
index 0000000..4965ef3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u32.c
@@ -0,0 +1,15 @@
+/* { dg-do run { target { rv32 || rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint32_t
+#define NAME usmul
+#define DATA TEST_BINARY_DATA_WRAP(NT, NAME)
+#define T TEST_BINARY_STRUCT_DECL_WRAP(NT, NAME)
+#define RUN_BINARY(x, y) RUN_SAT_U_MUL_FMT_2_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_2_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u64.c
new file mode 100644
index 0000000..1868e81
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u64.c
@@ -0,0 +1,15 @@
+/* { dg-do run { target { rv32 || rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint64_t
+#define NAME usmul
+#define DATA TEST_BINARY_DATA_WRAP(NT, NAME)
+#define T TEST_BINARY_STRUCT_DECL_WRAP(NT, NAME)
+#define RUN_BINARY(x, y) RUN_SAT_U_MUL_FMT_2_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_2_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u8.c
new file mode 100644
index 0000000..2b2551c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-3-u8.c
@@ -0,0 +1,15 @@
+/* { dg-do run { target { rv32 || rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint8_t
+#define NAME usmul
+#define DATA TEST_BINARY_DATA_WRAP(NT, NAME)
+#define T TEST_BINARY_STRUCT_DECL_WRAP(NT, NAME)
+#define RUN_BINARY(x, y) RUN_SAT_U_MUL_FMT_2_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_2_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"