diff options
author | Pan Li <pan2.li@intel.com> | 2024-08-25 11:02:10 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-08-26 09:17:35 +0800 |
commit | 5ab1e238aa23d1773429f8f28abfb6ed16f655f6 (patch) | |
tree | e771437930ffb48bf7465a8fefb93664e41d07b2 /gcc | |
parent | 07b7098b6eacfe5c95f679058bf2cb98dfec75b5 (diff) | |
download | gcc-5ab1e238aa23d1773429f8f28abfb6ed16f655f6.zip gcc-5ab1e238aa23d1773429f8f28abfb6ed16f655f6.tar.gz gcc-5ab1e238aa23d1773429f8f28abfb6ed16f655f6.tar.bz2 |
RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 4
This patch would like to add test cases for the unsigned scalar quad and
oct .SAT_TRUNC form 4. Aka:
Form 4:
#define DEF_SAT_U_TRUNC_FMT_4(NT, WT) \
NT __attribute__((noinline)) \
sat_u_trunc_##WT##_to_##NT##_fmt_4 (WT x) \
{ \
bool not_overflow = x <= (WT)(NT)(-1); \
return ((NT)x) | (NT)((NT)not_overflow - 1); \
}
The below test is passed for this patch.
* The rv64gcv regression test.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_u_trunc-19.c: New test.
* gcc.target/riscv/sat_u_trunc-20.c: New test.
* gcc.target/riscv/sat_u_trunc-21.c: New test.
* gcc.target/riscv/sat_u_trunc-22.c: New test.
* gcc.target/riscv/sat_u_trunc-23.c: New test.
* gcc.target/riscv/sat_u_trunc-24.c: New test.
* gcc.target/riscv/sat_u_trunc-run-19.c: New test.
* gcc.target/riscv/sat_u_trunc-run-20.c: New test.
* gcc.target/riscv/sat_u_trunc-run-21.c: New test.
* gcc.target/riscv/sat_u_trunc-run-22.c: New test.
* gcc.target/riscv/sat_u_trunc-run-23.c: New test.
* gcc.target/riscv/sat_u_trunc-run-24.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_arith.h | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-19.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-20.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-21.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-22.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-23.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-24.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-19.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-20.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-21.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-22.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-23.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-24.c | 16 |
13 files changed, 218 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 91853b6..229e1f0 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -245,6 +245,15 @@ sat_u_trunc_##WT##_to_##NT##_fmt_3 (WT x) \ } #define DEF_SAT_U_TRUNC_FMT_3_WRAP(NT, WT) DEF_SAT_U_TRUNC_FMT_3(NT, WT) +#define DEF_SAT_U_TRUNC_FMT_4(NT, WT) \ +NT __attribute__((noinline)) \ +sat_u_trunc_##WT##_to_##NT##_fmt_4 (WT x) \ +{ \ + bool not_overflow = x <= (WT)(NT)(-1); \ + return ((NT)x) | (NT)((NT)not_overflow - 1); \ +} +#define DEF_SAT_U_TRUNC_FMT_4_WRAP(NT, WT) DEF_SAT_U_TRUNC_FMT_4(NT, WT) + #define RUN_SAT_U_TRUNC_FMT_1(NT, WT, x) sat_u_trunc_##WT##_to_##NT##_fmt_1 (x) #define RUN_SAT_U_TRUNC_FMT_1_WRAP(NT, WT, x) RUN_SAT_U_TRUNC_FMT_1(NT, WT, x) @@ -254,4 +263,7 @@ sat_u_trunc_##WT##_to_##NT##_fmt_3 (WT x) \ #define RUN_SAT_U_TRUNC_FMT_3(NT, WT, x) sat_u_trunc_##WT##_to_##NT##_fmt_3 (x) #define RUN_SAT_U_TRUNC_FMT_3_WRAP(NT, WT, x) RUN_SAT_U_TRUNC_FMT_3(NT, WT, x) +#define RUN_SAT_U_TRUNC_FMT_4(NT, WT, x) sat_u_trunc_##WT##_to_##NT##_fmt_4 (x) +#define RUN_SAT_U_TRUNC_FMT_4_WRAP(NT, WT, x) RUN_SAT_U_TRUNC_FMT_4(NT, WT, x) + #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-19.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-19.c new file mode 100644 index 0000000..e61faff --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-19.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint16_t_to_uint8_t_fmt_4: +** sltiu\s+[atx][0-9]+,\s*a0,\s*255 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint8_t, uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-20.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-20.c new file mode 100644 index 0000000..708b2b2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-20.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint32_t_to_uint16_t_fmt_4: +** li\s+[atx][0-9]+,\s*65536 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint16_t, uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-21.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-21.c new file mode 100644 index 0000000..e522a90 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-21.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint64_t_to_uint32_t_fmt_4: +** li\s+[atx][0-9]+,\s*-1 +** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32 +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint32_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-22.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-22.c new file mode 100644 index 0000000..db75cd0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-22.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint32_t_to_uint8_t_fmt_4: +** sltiu\s+[atx][0-9]+,\s*a0,\s*255 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint8_t, uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-23.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-23.c new file mode 100644 index 0000000..7acc658 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-23.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint64_t_to_uint8_t_fmt_4: +** sltiu\s+[atx][0-9]+,\s*a0,\s*255 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** andi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*0xff +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint8_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-24.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-24.c new file mode 100644 index 0000000..32952f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-24.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_trunc_uint64_t_to_uint16_t_fmt_4: +** li\s+[atx][0-9]+,\s*65536 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** sltu\s+[atx][0-9]+,\s*a0,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** or\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_TRUNC_FMT_4(uint16_t, uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_TRUNC " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-19.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-19.c new file mode 100644 index 0000000..7f52283 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-19.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint8_t +#define T2 uint16_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-20.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-20.c new file mode 100644 index 0000000..ee13f0a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-20.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint16_t +#define T2 uint32_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-21.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-21.c new file mode 100644 index 0000000..a1b8a5f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-21.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint32_t +#define T2 uint64_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-22.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-22.c new file mode 100644 index 0000000..f056bd4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-22.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint8_t +#define T2 uint32_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-23.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-23.c new file mode 100644 index 0000000..96c06eb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-23.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint8_t +#define T2 uint64_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-24.c b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-24.c new file mode 100644 index 0000000..1623e52 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-24.c @@ -0,0 +1,16 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" +#include "sat_arith_data.h" + +#define T1 uint16_t +#define T2 uint64_t + +DEF_SAT_U_TRUNC_FMT_4_WRAP(T1, T2) + +#define DATA TEST_UNARY_DATA_WRAP(T1, T2) +#define T TEST_UNARY_STRUCT_DECL(T1, T2) +#define RUN_UNARY(x) RUN_SAT_U_TRUNC_FMT_4_WRAP(T1, T2, x) + +#include "scalar_sat_unary.h" |