]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Add test cases for scalar unsigned SAT form 10
authorPan Li <pan2.li@intel.com>
Tue, 12 May 2026 14:28:06 +0000 (22:28 +0800)
committerPan Li <pan2.li@intel.com>
Sat, 16 May 2026 07:38:53 +0000 (15:38 +0800)
Form 10 is supported already, add test to make sure of it.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add form 10.
* gcc.target/riscv/sat/sat_u_mul-11-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u8.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u16.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u16.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u8.c [new file with mode: 0644]

index 16d29c85f42b40f858cbf76b8186d5c2fbdfa42f..cc55228b0ad5f56f3e3def50cf5e8ca321307dd6 100644 (file)
@@ -811,4 +811,16 @@ sat_u_mul_##T##_fmt_9 (T a, T b)                               \
 #define RUN_SAT_U_MUL_FMT_9(T, a, b) sat_u_mul_##T##_fmt_9(a, b)
 #define RUN_SAT_U_MUL_FMT_9_WRAP(T, a, b) RUN_SAT_U_MUL_FMT_9(T, a, b)
 
+#define DEF_SAT_U_MUL_FMT_10(T)                                     \
+T __attribute__((noinline))                                         \
+sat_u_mul_##T##_fmt_10 (T a, T b)                                   \
+{                                                                   \
+  T result;                                                         \
+  return __builtin_mul_overflow (a, b, &result) == 0 ? result : -1; \
+}
+
+#define DEF_SAT_U_MUL_FMT_10_WRAP(T) DEF_SAT_U_MUL_FMT_10(T)
+#define RUN_SAT_U_MUL_FMT_10(T, a, b) sat_u_mul_##T##_fmt_10(a, b)
+#define RUN_SAT_U_MUL_FMT_10_WRAP(T, a, b) RUN_SAT_U_MUL_FMT_10(T, a, b)
+
 #endif
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u16.c
new file mode 100644 (file)
index 0000000..c141bd0
--- /dev/null
@@ -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_10_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-11-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u32.c
new file mode 100644 (file)
index 0000000..17b2495
--- /dev/null
@@ -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_10_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-11-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u64.c
new file mode 100644 (file)
index 0000000..dde927e
--- /dev/null
@@ -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_10_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-11-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-11-u8.c
new file mode 100644 (file)
index 0000000..5455667
--- /dev/null
@@ -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_10_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-11-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u16.c
new file mode 100644 (file)
index 0000000..1bbe893
--- /dev/null
@@ -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_10_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_10_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u32.c
new file mode 100644 (file)
index 0000000..81aff66
--- /dev/null
@@ -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_10_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_10_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u64.c
new file mode 100644 (file)
index 0000000..4205009
--- /dev/null
@@ -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_10_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_10_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-11-u8.c
new file mode 100644 (file)
index 0000000..3b0f491
--- /dev/null
@@ -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_10_WRAP(NT, x, y)
+
+DEF_SAT_U_MUL_FMT_10_WRAP(NT)
+
+#include "scalar_sat_binary_run_xxx.h"