Due to the test only patch. Therefore I will commit it directly if no comments in next 48H.
Pan -----Original Message----- From: Li, Pan2 <[email protected]> Sent: Thursday, June 4, 2026 11:06 PM To: [email protected] Cc: [email protected]; [email protected]; [email protected]; [email protected]; Chen, Ken <[email protected]>; Liu, Hongtao <[email protected]>; Li, Pan2 <[email protected]> Subject: [PATCH v1] RISC-V: Add testcase for unsigned scalar SAT_MUL form 12 From: Pan Li <[email protected]> The form 12 of unsigned scalar SAT_MUL has supported from the previous change. Thus, add the test cases to make sure it works well. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat/sat_u_mul-13-u16.c: New test. * gcc.target/riscv/sat/sat_u_mul-13-u32.c: New test. * gcc.target/riscv/sat/sat_u_mul-13-u64.c: New test. * gcc.target/riscv/sat/sat_u_mul-13-u8.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-13-u16.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-13-u32.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-13-u64.c: New test. * gcc.target/riscv/sat/sat_u_mul-run-13-u8.c: New test. Signed-off-by: Pan Li <[email protected]> --- gcc/testsuite/gcc.target/riscv/sat/sat_arith.h | 15 +++++++++++++++ .../gcc.target/riscv/sat/sat_u_mul-13-u16.c | 11 +++++++++++ .../gcc.target/riscv/sat/sat_u_mul-13-u32.c | 11 +++++++++++ .../gcc.target/riscv/sat/sat_u_mul-13-u64.c | 11 +++++++++++ .../gcc.target/riscv/sat/sat_u_mul-13-u8.c | 11 +++++++++++ .../gcc.target/riscv/sat/sat_u_mul-run-13-u16.c | 15 +++++++++++++++ .../gcc.target/riscv/sat/sat_u_mul-run-13-u32.c | 15 +++++++++++++++ .../gcc.target/riscv/sat/sat_u_mul-run-13-u64.c | 15 +++++++++++++++ .../gcc.target/riscv/sat/sat_u_mul-run-13-u8.c | 15 +++++++++++++++ 9 files changed, 119 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u64.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u8.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u16.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u32.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u64.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u8.c diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h index ca842eb5a07..bc382db28c7 100644 --- a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h @@ -838,4 +838,19 @@ sat_u_mul_##NT##_from_##WT##_fmt_11 (NT a, NT b) \ sat_u_mul_##NT##_from_##WT##_fmt_11 (a, b) #define RUN_SAT_U_MUL_FMT_11_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_11(NT, WT, a, b) +#define DEF_SAT_U_MUL_FMT_12(T) \ +T __attribute__((noinline)) \ +sat_u_mul_##T##_fmt_12 (T a, T b) \ +{ \ + T result; \ + if (!__builtin_mul_overflow(a, b, &result)) \ + return result; \ + else \ + return -1; \ +} + +#define DEF_SAT_U_MUL_FMT_12_WRAP(T) DEF_SAT_U_MUL_FMT_12(T) +#define RUN_SAT_U_MUL_FMT_12(T, a, b) sat_u_mul_##T##_fmt_12(a, b) +#define RUN_SAT_U_MUL_FMT_12_WRAP(T, a, b) RUN_SAT_U_MUL_FMT_12(T, a, b) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u16.c new file mode 100644 index 00000000000..492f430cd54 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-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_12_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-13-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u32.c new file mode 100644 index 00000000000..b3ee780dfac --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-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_12_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-13-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u64.c new file mode 100644 index 00000000000..b857dc6e4c4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-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_12_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-13-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-u8.c new file mode 100644 index 00000000000..fe4c59aab96 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-13-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_12_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-13-u16.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u16.c new file mode 100644 index 00000000000..13e98ef50e8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-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_12_WRAP(NT, x, y) + +DEF_SAT_U_MUL_FMT_12_WRAP(NT) + +#include "scalar_sat_binary_run_xxx.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u32.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u32.c new file mode 100644 index 00000000000..dbd7a22c33e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-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_12_WRAP(NT, x, y) + +DEF_SAT_U_MUL_FMT_12_WRAP(NT) + +#include "scalar_sat_binary_run_xxx.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u64.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u64.c new file mode 100644 index 00000000000..63926a7e517 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-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_12_WRAP(NT, x, y) + +DEF_SAT_U_MUL_FMT_12_WRAP(NT) + +#include "scalar_sat_binary_run_xxx.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u8.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-u8.c new file mode 100644 index 00000000000..48aba3c84a0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-13-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_12_WRAP(NT, x, y) + +DEF_SAT_U_MUL_FMT_12_WRAP(NT) + +#include "scalar_sat_binary_run_xxx.h" -- 2.43.0
