[v2,2/2] RISC-V: Add test case of unsigned scalar SAT_MUL form 5 for widen-mul
Checks
| Context |
Check |
Description |
| rivoscibot/toolchain-ci-rivos-apply-patch |
success
|
Patch applied
|
| rivoscibot/toolchain-ci-rivos-lint |
warning
|
Lint failed
|
| rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib |
success
|
Build passed
|
| rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib |
success
|
Build passed
|
| rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib |
success
|
Build passed
|
| rivoscibot/toolchain-ci-rivos-test |
fail
|
Testing failed
|
Commit Message
From: Pan Li <pan2.li@intel.com>
The form 5 of unsigned scalar SAT_MUL is covered in middle-expand
alreay, add test case here to cover form 5.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
---
gcc/testsuite/gcc.target/riscv/sat/sat_arith.h | 15 +++++++++++++++
.../riscv/sat/sat_u_mul-6-u16-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u32-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u64-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u8-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-run-6-u16-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u32-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u64-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u8-from-u128.c | 16 ++++++++++++++++
9 files changed, 123 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c
Comments
Will commit the series if no more comments for test in next 24H.
Pan
-----Original Message-----
From: Li, Pan2 <pan2.li@intel.com>
Sent: Tuesday, September 16, 2025 11:20 AM
To: gcc-patches@gcc.gnu.org
Cc: juzhe.zhong@rivai.ai; kito.cheng@gmail.com; jeffreyalaw@gmail.com; rdapp.gcc@gmail.com; Chen, Ken <ken.chen@intel.com>; Liu, Hongtao <hongtao.liu@intel.com>; richard.guenther@gmail.com; Li, Pan2 <pan2.li@intel.com>
Subject: [PATCH v2 2/2] RISC-V: Add test case of unsigned scalar SAT_MUL form 5 for widen-mul
From: Pan Li <pan2.li@intel.com>
The form 5 of unsigned scalar SAT_MUL is covered in middle-expand
alreay, add test case here to cover form 5.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
---
gcc/testsuite/gcc.target/riscv/sat/sat_arith.h | 15 +++++++++++++++
.../riscv/sat/sat_u_mul-6-u16-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u32-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u64-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-6-u8-from-u128.c | 11 +++++++++++
.../riscv/sat/sat_u_mul-run-6-u16-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u32-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u64-from-u128.c | 16 ++++++++++++++++
.../riscv/sat/sat_u_mul-run-6-u8-from-u128.c | 16 ++++++++++++++++
9 files changed, 123 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c
create mode 100644 gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
index 035545c9e0f..7cd16a29648 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
@@ -741,4 +741,19 @@ sat_u_mul_##NT##_from_##WT##_fmt_4 (NT a, NT b) \
sat_u_mul_##NT##_from_##WT##_fmt_4 (a, b)
#define RUN_SAT_U_MUL_FMT_4_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_4(NT, WT, a, b)
+#define DEF_SAT_U_MUL_FMT_5(NT, WT) \
+NT __attribute__((noinline)) \
+sat_u_mul_##NT##_from_##WT##_fmt_5 (NT a, NT b) \
+{ \
+ WT x = (WT)a * (WT)b; \
+ NT hi = x >> (sizeof(NT) * 8); \
+ NT lo = (NT)x; \
+ return lo | -!!hi; \
+}
+
+#define DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT) DEF_SAT_U_MUL_FMT_5(NT, WT)
+#define RUN_SAT_U_MUL_FMT_5(NT, WT, a, b) \
+ sat_u_mul_##NT##_from_##WT##_fmt_5 (a, b)
+#define RUN_SAT_U_MUL_FMT_5_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_5(NT, WT, a, b)
+
#endif
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c
new file mode 100644
index 00000000000..d5896650036
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint16_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c
new file mode 100644
index 00000000000..6a074228492
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint32_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c
new file mode 100644
index 00000000000..438b420f95a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint64_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c
new file mode 100644
index 00000000000..9dbb434d56a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint8_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c
new file mode 100644
index 00000000000..88fe3a74e56
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint8_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c
new file mode 100644
index 00000000000..c8d802efdf4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint32_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c
new file mode 100644
index 00000000000..acc999fc748
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint64_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c
new file mode 100644
index 00000000000..88fe3a74e56
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint8_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
@@ -741,4 +741,19 @@ sat_u_mul_##NT##_from_##WT##_fmt_4 (NT a, NT b) \
sat_u_mul_##NT##_from_##WT##_fmt_4 (a, b)
#define RUN_SAT_U_MUL_FMT_4_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_4(NT, WT, a, b)
+#define DEF_SAT_U_MUL_FMT_5(NT, WT) \
+NT __attribute__((noinline)) \
+sat_u_mul_##NT##_from_##WT##_fmt_5 (NT a, NT b) \
+{ \
+ WT x = (WT)a * (WT)b; \
+ NT hi = x >> (sizeof(NT) * 8); \
+ NT lo = (NT)x; \
+ return lo | -!!hi; \
+}
+
+#define DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT) DEF_SAT_U_MUL_FMT_5(NT, WT)
+#define RUN_SAT_U_MUL_FMT_5(NT, WT, a, b) \
+ sat_u_mul_##NT##_from_##WT##_fmt_5 (a, b)
+#define RUN_SAT_U_MUL_FMT_5_WRAP(NT, WT, a, b) RUN_SAT_U_MUL_FMT_5(NT, WT, a, b)
+
#endif
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint16_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint32_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint64_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized" } */
+
+#include "sat_arith.h"
+
+#define NT uint8_t
+#define WT uint128_t
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+/* { dg-final { scan-tree-dump-times ".SAT_MUL" 1 "optimized" } } */
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint8_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint32_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint64_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "sat_arith.h"
+#include "sat_arith_data.h"
+
+#define NT uint8_t
+#define WT uint128_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_5_WRAP(NT, WT, x, y)
+
+DEF_SAT_U_MUL_FMT_5_WRAP(NT, WT)
+
+#include "scalar_sat_binary_run_xxx.h"