https://gcc.gnu.org/g:f59c712d537a6674035ef675ed539f9a5c818666

commit f59c712d537a6674035ef675ed539f9a5c818666
Author: Pan Li <pan2...@intel.com>
Date:   Mon Sep 1 09:43:24 2025 +0800

    RISC-V: Add test case of unsigned scalar SAT_MUL form 5 for widen-mul
    
    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...@intel.com>
    (cherry picked from commit 80e85c627a38e2206a970cc1630d958e45cdfdf5)

Diff:
---
 gcc/testsuite/gcc.target/riscv/sat/sat_arith.h           | 15 +++++++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c     | 11 +++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c     | 11 +++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c     | 11 +++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c      | 11 +++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c | 16 ++++++++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c | 16 ++++++++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c | 16 ++++++++++++++++
 .../gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c  | 16 ++++++++++++++++
 9 files changed, 123 insertions(+)

diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h 
b/gcc/testsuite/gcc.target/riscv/sat/sat_arith.h
index 035545c9e0fb..7cd16a296484 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 000000000000..d58966500369
--- /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 000000000000..6a0742284928
--- /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 000000000000..438b420f95a3
--- /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 000000000000..9dbb434d56a5
--- /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 000000000000..88fe3a74e568
--- /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 000000000000..c8d802efdf41
--- /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 000000000000..acc999fc748a
--- /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 000000000000..88fe3a74e568
--- /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"

Reply via email to