[PATCH v4] RISC-V: Make sure high bits of usadd operands is clean for non-Xmode [PR116278]

2024-08-16 Thread pan2 . li
From: Pan Li For QI/HImode of .SAT_ADD, the operands may be sign-extended and the high bits of Xmode may be all 1 which is not expected. For example as below code. signed char b[1]; unsigned short c; signed char *d = b; int main() { b[0] = -40; c = ({ (unsigned short)d[0] < 0xFFF6 ? (unsig

[PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 2

2024-08-17 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar .SAT_TRUNC form 2. Aka: Form 2: #define DEF_SAT_U_TRUC_FMT_2(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ {\ WT

[PATCH v1 2/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 3

2024-08-17 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar .SAT_TRUNC form 3. Aka: Form 3: #define DEF_SAT_U_TRUC_FMT_3(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \ {\ WT

[PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 2

2024-08-17 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 2. Aka: Form 2: #define DEF_SAT_U_TRUC_FMT_2(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ {

[PATCH v1 2/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 3

2024-08-17 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 3. Aka: Form 3: #define DEF_SAT_U_TRUC_FMT_3(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \ {

[PATCH v1] Test: Move pr116278 run test to c-torture [NFC]

2024-08-18 Thread pan2 . li
From: Pan Li Move the run test of pr116278 to c-torture and leave the risc-v the asm check under risc-v part. PR target/116278 gcc/testsuite/ChangeLog: * gcc.target/riscv/pr116278-run-1.c: Take compile instead of run test. * gcc.target/riscv/pr116278-run-2.c: Di

[PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 2

2024-08-18 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 2. Aka: Form 2: #define DEF_SAT_U_TRUC_FMT_2(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ {

[PATCH v2] Test: Move pr116278 run test to dg/torture [NFC]

2024-08-18 Thread pan2 . li
From: Pan Li Move the run test of pr116278 to dg/torture and leave the risc-v the asm check under risc-v part. PR target/116278 gcc/testsuite/ChangeLog: * gcc.target/riscv/pr116278-run-1.c: Take compile instead of run. * gcc.target/riscv/pr116278-run-2.c: Ditto.

[PATCH v3] RISC-V: Support IMM for operand 0 of ussub pattern

2024-08-18 Thread pan2 . li
From: Pan Li This patch would like to allow IMM for the operand 0 of ussub pattern. Aka .SAT_SUB(1023, y) as the below example. Form 1: #define DEF_SAT_U_SUB_IMM_FMT_1(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_1 (T y) \ {

[PATCH v1] Match: Support form 4 for unsigned integer .SAT_TRUNC

2024-08-20 Thread pan2 . li
From: Pan Li This patch would like to support the form 4 of the unsigned integer .SAT_TRUNC. Aka below example: Form 4: #define DEF_SAT_U_TRUC_FMT_4(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_4 (WT x) \ {

[PATCH v1] RISC-V: Fix one typo in .SAT_TRUNC test func name [NFC]

2024-08-20 Thread pan2 . li
From: Pan Li Fix one typo `sat_truc` to `sat_trunc`, as well as `SAT_TRUC` to `SAT_TRUNC`. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_arith.h: Fix SAT_TRUNC typo. * gcc.target/riscv/sat_u_trunc-1.c: Ditto. * gcc.target/riscv/sat_u_trunc-13.c: Ditto. * gcc.ta

[PATCH v1 1/2] RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 2

2024-08-21 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned vector .SAT_TRUNC form 2. Aka: Form 2: #define DEF_VEC_SAT_U_TRUNC_FMT_2(NT, WT) \ void __attribute__((noinline))\ vec_sat_u_trunc_##NT##_##WT##_fmt_2

[PATCH v1 2/2] RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 3

2024-08-21 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned vector .SAT_TRUNC form 3. Aka: Form 3: #define DEF_VEC_SAT_U_TRUNC_FMT_3(NT, WT) \ void __attribute__((noinline))\ vec_sat_u_trunc_##NT##_##WT##_fmt_3

[PATCH v1] Match: Add type check for .SAT_ADD imm operand

2024-08-24 Thread pan2 . li
From: Pan Li This patch would like to add strict check for imm operand of .SAT_ADD matching. We have no type checking for imm operand in previous, which may result in unexpected IL to be catched by .SAT_ADD pattern. However, things may become more complicated due to the int promotion. This me

[PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar .SAT_TRUNC form 4

2024-08-24 Thread pan2 . li
From: Pan Li 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) \ {

[PATCH v1 2/2] RISC-V: Add testcases for unsigned vector .SAT_TRUNC form 4

2024-08-24 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned vector .SAT_TRUNC form 4. Aka: Form 4: #define DEF_VEC_SAT_U_TRUNC_FMT_4(NT, WT) \ void __attribute__((noinline))\ vec_sat_u_trunc_##NT##_##WT##_fmt_4

[PATCH v3] Match: Support form 1 for scalar signed integer .SAT_ADD

2024-08-25 Thread pan2 . li
From: Pan Li This patch would like to support the form 1 of the scalar signed integer .SAT_ADD. Aka below example: Form 1: #define DEF_SAT_S_ADD_FMT_1(T, UT, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_add_##T##_fmt_1 (T x, T y) \ {

[PATCH v2] Match: Add int type fits check for .SAT_ADD imm operand

2024-08-26 Thread pan2 . li
From: Pan Li This patch would like to add strict check for imm operand of .SAT_ADD matching. We have no type checking for imm operand in previous, which may result in unexpected IL to be catched by .SAT_ADD pattern. We leverage the int_fits_type_p here to make sure the imm operand is a int type

[PATCH v1] RISC-V: Support IMM for operand 1 of ussub pattern

2024-08-26 Thread pan2 . li
From: Pan Li This patch would like to allow IMM for the operand 1 of ussub pattern. Aka .SAT_SUB(x, 22) as the below example. Form 2: #define DEF_SAT_U_SUB_IMM_FMT_2(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_2 (T x) \ {

[PATCH v2] Vect: Reconcile the const_int operand type of unsigned .SAT_ADD

2024-08-27 Thread pan2 . li
From: Pan Li The .SAT_ADD has 2 operand, when one of the operand may be INTEGER_CST. For example _1 = .SAT_ADD (_2, 9) comes from below sample code. Form 3: #define DEF_VEC_SAT_U_ADD_IMM_FMT_3(T, IMM) \ T __attribute__((noinline))

[PATCH v1 1/2] RISC-V: Add testcases for unsigned scalar .SAT_SUB IMM form 3

2024-08-27 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar .SAT_SUB IMM form 3. Aka: Form 3: #define DEF_SAT_U_SUB_IMM_FMT_3(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_3 (T y) \ { \ retu

[PATCH v1 2/2] RISC-V: Add testcases for unsigned scalar .SAT_SUB IMM form 4

2024-08-27 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar .SAT_SUB IMM form 4. Aka: Form 4: #define DEF_SAT_U_SUB_IMM_FMT_4(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_4 (T x) \ { \ retu

[PATCH v4] Match: Support form 1 for scalar signed integer .SAT_ADD

2024-08-27 Thread pan2 . li
From: Pan Li This patch would like to support the form 1 of the scalar signed integer .SAT_ADD. Aka below example: Form 1: #define DEF_SAT_S_ADD_FMT_1(T, UT, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_add_##T##_fmt_1 (T x, T y) \ {

[PATCH v3] Vect: Reconcile the const_int operand type of unsigned .SAT_ADD

2024-08-27 Thread pan2 . li
From: Pan Li The .SAT_ADD has 2 operand, when one of the operand may be INTEGER_CST. For example _1 = .SAT_ADD (_2, 9) comes from below sample code. Form 3: #define DEF_VEC_SAT_U_ADD_IMM_FMT_3(T, IMM) \ T __attribute__((noinline))

[PATCH v1] RISC-V: Support form 1 of integer scalar .SAT_ADD

2024-08-28 Thread pan2 . li
From: Pan Li This patch would like to support the scalar signed ssadd pattern for the RISC-V backend. Aka Form 1: #define DEF_SAT_S_ADD_FMT_1(T, UT, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_add_##T##_fmt_1 (T x, T y) \ {

[PATCH v2 2/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 3

2024-08-29 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 3. Aka: Form 3: #define DEF_SAT_U_TRUC_FMT_3(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \ {

[PATCH v2 1/2] RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 2

2024-08-29 Thread pan2 . li
From: Pan Li This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 2. Aka: Form 2: #define DEF_SAT_U_TRUC_FMT_2(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ {

[PATCH v1] RISC-V: Implement .SAT_SUB for unsigned scalar int

2024-06-05 Thread pan2 . li
From: Pan Li As the middle support of .SAT_SUB committed, implement the unsigned scalar int of .SAT_SUB for the riscv backend. Consider below example code: T __attribute__((noinline))\ sat_u_sub_##T##_fmt_1 (T x, T y) \ { \ return (x - y) & (-(T)(x

[PATCH v2] Vect: Support IFN SAT_SUB for unsigned vector int

2024-06-05 Thread pan2 . li
From: Pan Li This patch would like to support the .SAT_SUB for the unsigned vector int. Given we have below example code: void vec_sat_sub_u64 (uint64_t *out, uint64_t *x, uint64_t *y, unsigned n) { for (unsigned i = 0; i < n; i++) out[i] = (x[i] - y[i]) & (-(uint64_t)(x[i] >= y[i])); }

[PATCH v7] Match: Support more form for scalar unsigned SAT_ADD

2024-06-06 Thread pan2 . li
From: Pan Li After we support one gassign form of the unsigned .SAT_ADD, we would like to support more forms including both the branch and branchless. There are 5 other forms of .SAT_ADD, list as below: Form 1: #define SAT_ADD_U_1(T) \ T sat_add_u_1_##T(T x, T y) \ { \ return (T)(x

[PATCH v2] RISC-V: Implement .SAT_SUB for unsigned scalar int

2024-06-06 Thread pan2 . li
From: Pan Li As the middle support of .SAT_SUB committed, implement the unsigned scalar int of .SAT_SUB for the riscv backend. Consider below example code: T __attribute__((noinline))\ sat_u_sub_##T##_fmt_1 (T x, T y) \ { \ return (x - y) & (-(T)(x

[PATCH v3] RISC-V: Implement .SAT_SUB for unsigned scalar int

2024-06-07 Thread pan2 . li
From: Pan Li As the middle support of .SAT_SUB committed, implement the unsigned scalar int of .SAT_SUB for the riscv backend. Consider below example code: T __attribute__((noinline))\ sat_u_sub_##T##_fmt_1 (T x, T y) \ { \ return (x - y) & (-(T)(x

[PATCH v1] Widening-Mul: Fix one ICE of gcall insertion for PHI match

2024-06-10 Thread pan2 . li
From: Pan Li When enabled the PHI handing for COND_EXPR, we need to insert the gcall to replace the PHI node. Unfortunately, I made a mistake that insert the gcall to before the last stmt of the bb. See below gimple, the PHI is located at no.1 but we insert the gcall (aka no.9) to the end of

[PATCH v1] Test: Move target independent test cases to gcc.dg/torture

2024-06-10 Thread pan2 . li
From: Pan Li The test cases of pr115387 are target independent, at least x86 and riscv are able to reproduce. Thus, move these cases to the gcc.dg/torture. The below test suites are passed. 1. The rv64gcv fully regression test. 2. The x86 fully regression test. gcc/testsuite/ChangeLog:

[PATCH v1] RISC-V: Implement .SAT_SUB for unsigned vector int

2024-06-11 Thread pan2 . li
From: Pan Li As the middle support of .SAT_SUB committed, implement the unsigned vector int of .SAT_SUB for the riscv backend. Consider below example code: void __attribute__((noinline)) \ vec_sat_u_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit

[PATCH v1] Widening-Mul: Take gsi after_labels instead of start_bb for gcall insertion

2024-06-11 Thread pan2 . li
From: Pan Li We inserted the gcall of .SAT_ADD before the gsi_start_bb for avoiding the ssa def after use ICE issue. Unfortunately, there will be the potential ICE when the first stmt is label. We cannot insert the gcall before the label. Thus, we take gsi_after_labels to locate the 'really'

[PATCH v2] Test: Move target independent test cases to gcc.dg/torture

2024-06-11 Thread pan2 . li
From: Pan Li The test cases of pr115387 are target independent, at least x86 and riscv are able to reproduce. Thus, move these cases to the gcc.dg/torture. The below test suites are passed. 1. The rv64gcv fully regression test. 2. The x86 fully regression test. gcc/testsuite/ChangeLog:

[PATCH v1] Match: Support more forms for the scalar unsigned .SAT_SUB

2024-06-12 Thread pan2 . li
From: Pan Li After we support the scalar unsigned form 1 and 2, we would like to introduce more forms include the branch and branchless. There are forms 3-10 list as below: Form 3: #define SAT_SUB_U_3(T) \ T sat_sub_u_3_##T (T x, T y) \ { \ return x > y ? x - y : 0; \ } Form 4:

[PATCH v1] RISC-V: Bugfix vec_extract vls mode iterator restriction mismatch

2024-06-13 Thread pan2 . li
From: Pan Li We have vec_extract pattern which takes ZVFHMIN as the mode iterator of the VLS mode. Aka V_VLS. But it will expand to pred_extract_first pattern which takes the ZVFH as the mode iterator of the VLS mode. AKa V_VLSF. The mismatch will result in one ICE similar as below: error: u

[PATCH v1 2/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 4

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 4 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 4 of unsigned .SAT_SUB. Form 4: #define SAT_SUB_U_4(T) \ T sat_sub_u_4_##T (T x, T y) \ { \ return x >= y ? x - y : 0; \

[PATCH v1 1/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 3

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 3 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 3 of unsigned .SAT_SUB. Form 3: #define SAT_SUB_U_3(T) \ T sat_sub_u_3_##T (T x, T y) \ { \ return x > y ? x - y : 0; \

[PATCH v1 6/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 8

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 8 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 8 of unsigned .SAT_SUB. Form 8: #define SAT_SUB_U_8(T) \ T sat_sub_u_8_##T (T x, T y) \ { \ T ret; \ T overflow = __bu

[PATCH v1 5/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 7

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 7 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 7 of unsigned .SAT_SUB. Form 7: #define SAT_SUB_U_7(T) \ T sat_sub_u_7_##T (T x, T y) \ { \ T ret; \ T overflow = __bu

[PATCH v1 3/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 5

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 5 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 5 of unsigned .SAT_SUB. Form 5: #define SAT_SUB_U_5(T) \ T sat_sub_u_5_##T (T x, T y) \ { \ return x < y ? 0 : x - y; \

[PATCH v1 4/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 6

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 6 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 6 of unsigned .SAT_SUB. Form 6: #define SAT_SUB_U_6(T) \ T sat_sub_u_6_##T (T x, T y) \ { \ return x <= y ? 0 : x - y; \

[PATCH v1 7/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 9

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 9 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 9 of unsigned .SAT_SUB. Form 9: #define SAT_SUB_U_9(T) \ T sat_sub_u_9_##T (T x, T y) \ { \ T ret; \ T overflow = __bu

[PATCH v1 8/8] RISC-V: Add testcases for scalar unsigned SAT_SUB form 10

2024-06-13 Thread pan2 . li
From: Pan Li After the middle-end support the form 10 of unsigned SAT_SUB and the RISC-V backend implement the scalar .SAT_SUB, add more test case to cover the form 10 of unsigned .SAT_SUB. Form 10: #define SAT_SUB_U_10(T) \ T sat_sub_u_10_##T (T x, T y) \ { \ T ret; \ T overflow =

[PATCH v1] RISC-V: Bugfix vec_extract v mode iterator restriction mismatch

2024-06-14 Thread pan2 . li
From: Pan Li We have vec_extract pattern which takes ZVFHMIN as the mode iterator of the V mode. Aka VF_ZVFHMIN iterator. But it will expand to pred_extract_first pattern which takes the ZVFH as the mode iterator of the V mode. AKa VF. The mismatch will result in one ICE similar as below: in

[PATCH v1] RISC-V: Refine the SAT_ARITH test help header files [NFC]

2024-06-14 Thread pan2 . li
From: Pan Li Separate the vector part code to one standalone header file, which is independent with the scalar part. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Leverage the new header file for vector part. * gcc.target/riscv/rvv/aut

[PATCH v1] RISC-V: Add testcases for vector unsigned SAT_SUB form 2

2024-06-15 Thread pan2 . li
From: Pan Li The previous RISC-V backend .SAT_SUB enabling patch missed the form 2 testcases of vector modes. Aka: Form 2: #define DEF_VEC_SAT_U_SUB_FMT_2(T) \ void __attribute__((noinline)) \ vec_sat_u_sub_##T##_fmt_

[PATCH v1] Match: Support forms 7 and 8 for the unsigned .SAT_ADD

2024-06-16 Thread pan2 . li
From: Pan Li When investigate the vectorization of .SAT_ADD, we notice there are additional 2 forms, aka form 7 and 8 for .SAT_ADD. Form 7: #define DEF_SAT_U_ADD_FMT_7(T) \ T __attribute__((noinline)) \ sat_u_add_##T##_fmt_7 (T x, T y)\ {

[PATCH v1] Match: Support form 11 for the unsigned scalar .SAT_SUB

2024-06-17 Thread pan2 . li
From: Pan Li We missed one match pattern for the unsigned scalar .SAT_SUB, aka form 11. Form 11: #define SAT_SUB_U_11(T) \ T sat_sub_u_11_##T (T x, T y) \ { \ T ret; \ bool overflow = __builtin_sub_overflow (x, y, &ret); \ return overflow ? 0 : ret; \ } Thus, add above for

[PATCH v1 1/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 2

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 2 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 2. Form 2: #define DEF_VEC_SAT_U_ADD_FMT_2(T) \ void __attribute__((noinline))

[PATCH v1 2/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 3

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 3 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 3. Form 3: #define DEF_VEC_SAT_U_ADD_FMT_3(T) \ void __attribute__((noinline))

[PATCH v1 3/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 4

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 4 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 4. Form 4: #define DEF_VEC_SAT_U_ADD_FMT_4(T) \ void __attribute__((noinline))

[PATCH v1 4/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 5

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 5 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 5. Form 5: #define DEF_VEC_SAT_U_ADD_FMT_5(T) \ void __attribute__((noinline))

[PATCH v1 6/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 7

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 7 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 7. Form 7: #define DEF_VEC_SAT_U_ADD_FMT_7(T) \ void __attribute__((noinline))

[PATCH v1 5/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 6

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 6 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 6. Form 6: #define DEF_VEC_SAT_U_ADD_FMT_6(T) \ void __attribute__((noinline))

[PATCH v1 7/7] RISC-V: Add testcases for unsigned .SAT_ADD vector form 8

2024-06-17 Thread pan2 . li
From: Pan Li After the middle-end support the form 8 of unsigned SAT_ADD and the RISC-V backend implement the .SAT_ADD for vector mode, add more test case to cover the form 8. Form 8: #define DEF_VEC_SAT_U_ADD_FMT_8(T) \ void __attribute__((noinline))

[PATCH v1 1/2] RISC-V: Add testcases for unsigned .SAT_SUB scalar form 11

2024-06-18 Thread pan2 . li
From: Pan Li After the middle-end support the form 11 of unsigned SAT_SUB and the RISC-V backend implement the SAT_SUB for vector mode, add more test case to cover the form 11. Form 11: #define DEF_SAT_U_SUB_FMT_11(T)\ T __attribute__((noinline))

[PATCH v1 2/2] RISC-V: Add testcases for unsigned .SAT_SUB scalar form 12

2024-06-18 Thread pan2 . li
From: Pan Li After the middle-end support the form 12 of unsigned SAT_SUB and the RISC-V backend implement the SAT_SUB for vector mode, add more test case to cover the form 12. Form 12: #define DEF_SAT_U_SUB_FMT_12(T)\ T __attribute__((noinline))

[PATCH v1 1/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 3

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 3 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 3: #define DEF_VEC_SAT_U_SUB_FMT_3(T) \ void __attribute__((noinline))

[PATCH v1 2/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 4

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 4 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 4: #define DEF_VEC_SAT_U_SUB_FMT_4(T) \ void __attribute__((noinline))

[PATCH v1 6/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 8

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 8 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 8: #define DEF_VEC_SAT_U_SUB_FMT_8(T) \ void __attribute__((noinline))

[PATCH v1 3/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 5

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 5 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 5: #define DEF_VEC_SAT_U_SUB_FMT_5(T) \ void __attribute__((noinline))

[PATCH v1 7/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 9

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 9 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 9: #define DEF_VEC_SAT_U_SUB_FMT_9(T) \ void __attribute__((noinline))

[PATCH v1 4/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 6

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 6 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 6: #define DEF_VEC_SAT_U_SUB_FMT_6(T) \ void __attribute__((noinline))

[PATCH v1 8/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 10

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 10 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 10: #define DEF_VEC_SAT_U_SUB_FMT_10(T) \ void __attribute__((noinline))

[PATCH v1 5/8] RISC-V: Add testcases for unsigned .SAT_SUB vector form 7

2024-06-19 Thread pan2 . li
From: Pan Li After the middle-end support the form 7 of unsigned SAT_SUB and the RISC-V backend implement the .SAT_SUB for vector mode, thus add more test case to cover that. Form 7: #define DEF_VEC_SAT_U_SUB_FMT_7(T) \ void __attribute__((noinline))

[PATCH v1] Ifcvt: Add cond tree reconcile for truncated .SAT_SUB

2024-06-20 Thread pan2 . li
From: Pan Li The zip benchmark of coremark-pro have one SAT_SUB like pattern but truncated as below: void test (uint16_t *x, unsigned b, unsigned n) { unsigned a = 0; register uint16_t *p = x; do { a = *--p; *p = (uint16_t)(a >= b ? a - b : 0); // Truncate the result of SAT_SUB

[PATCH v2] Vect: Support truncate after .SAT_SUB pattern in zip

2024-06-24 Thread pan2 . li
From: Pan Li The zip benchmark of coremark-pro have one SAT_SUB like pattern but truncated as below: void test (uint16_t *x, unsigned b, unsigned n) { unsigned a = 0; register uint16_t *p = x; do { a = *--p; *p = (uint16_t)(a >= b ? a - b : 0); // Truncate after .SAT_SUB } while

[PATCH v1] RISC-V: Add testcases for vector truncate after .SAT_SUB

2024-06-25 Thread pan2 . li
From: Pan Li This patch would like to add the test cases of the vector truncate after .SAT_SUB. Aka: #define DEF_VEC_SAT_U_SUB_TRUNC_FMT_1(OUT_T, IN_T) \ void __attribute__((noinline)) \ vec_sat_u_sub_trunc_##OUT_T##_fmt_1 (OUT_T *ou

[PATCH v1] Internal-fn: Support new IFN SAT_TRUNC for unsigned scalar int

2024-06-25 Thread pan2 . li
From: Pan Li This patch would like to add the middle-end presentation for the saturation truncation. Aka set the result of truncated value to the max value when overflow. It will take the pattern similar as below. Form 1: #define DEF_SAT_U_TRUC_FMT_1(WT, NT) \ NT __attribute__((noinline))

[PATCH v1] RISC-V: Rearrange the test helper files for vector .SAT_*

2024-07-21 Thread pan2 . li
From: Pan Li Rearrange the test help header files, as well as align the name conventions. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vec_sat_binary.h: Move to... * gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_vvv_run.h: ...here. * gcc.target/risc

[PATCH v1] RISC-V: Implement the quad and oct .SAT_TRUNC for scalar

2024-07-22 Thread pan2 . li
From: Pan Li This patch would like to implement the quad and oct .SAT_TRUNC pattern in the riscv backend. Aka: Form 1: #define DEF_SAT_U_TRUC_FMT_1(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_1 (WT x) \ {

[PATCH v1] Match: Support .SAT_SUB with IMM op for form 1-4

2024-07-26 Thread pan2 . li
From: Pan Li This patch would like to support .SAT_SUB when one of the op is IMM. Aka below 1-4 forms. Form 1: #define DEF_SAT_U_SUB_IMM_FMT_1(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_1 (T y) \ { \ return IM

[PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM

2024-07-27 Thread pan2 . li
From: Pan Li After add the matching for .SAT_SUB when one op is IMM, there will be a new root PLUS_EXPR for the .SAT_SUB pattern. For example, Form 3: #define DEF_SAT_U_SUB_IMM_FMT_3(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_3 (T x) \ {

[PATCH v1] Internal-fn: Handle vector bool type for type strict match mode [PR116103]

2024-07-29 Thread pan2 . li
From: Pan Li For some target like target=amdgcn-amdhsa, we need to take care of vector bool types prior to general vector mode types. Or we may have the asm check failure as below. gcc.target/gcn/cond_smax_1.c scan-assembler-times \\tv_cmp_gt_i32\\tvcc, s[0-9]+, v[0-9]+ 80 gcc.target/gcn/cond

[PATCH v2] Internal-fn: Handle vector bool type for type strict match mode [PR116103]

2024-07-29 Thread pan2 . li
From: Pan Li For some target like target=amdgcn-amdhsa, we need to take care of vector bool types prior to general vector mode types. Or we may have the asm check failure as below. gcc.target/gcn/cond_smax_1.c scan-assembler-times \\tv_cmp_gt_i32\\tvcc, s[0-9]+, v[0-9]+ 80 gcc.target/gcn/cond

[PATCH v1] RISC-V: Take Xmode instead of Pmode for ussub expanding

2024-07-29 Thread pan2 . li
From: Pan Li The Pmode is designed for pointer, thus leverage the Xmode instead for the expanding of the ussub. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_ussub): Promote to Xmode instead of Pmode. Signed-off-by: Pan Li --- gcc/config/riscv/riscv.cc | 24 ++

[PATCH v1] RISC-V: Support IMM for operand 0 of ussub pattern

2024-08-03 Thread pan2 . li
From: Pan Li This patch would like to allow IMM for the operand 0 of ussub pattern. Aka .SAT_SUB(1023, y) as the below example. Form 1: #define DEF_SAT_U_SUB_IMM_FMT_1(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_1 (T y) \ {

[PATCH v1] Match: Add type_has_mode_precision_p check for SAT_TRUNC [PR116202]

2024-08-04 Thread pan2 . li
From: Pan Li The .SAT_TRUNC matching can only perform the type has its mode precision. g_12 = (long unsigned int) _2; _13 = MIN_EXPR ; _3 = (_Bool) _13; The above pattern cannot be recog as .SAT_TRUNC (g_12) because the dest only has 1 bit precision but QImode. Aka the type doesn't have the mo

[PATCH v2] RISC-V: Support IMM for operand 0 of ussub pattern

2024-08-04 Thread pan2 . li
From: Pan Li This patch would like to allow IMM for the operand 0 of ussub pattern. Aka .SAT_SUB(1023, y) as the below example. Form 1: #define DEF_SAT_U_SUB_IMM_FMT_1(T, IMM) \ T __attribute__((noinline)) \ sat_u_sub_imm##IMM##_##T##_fmt_1 (T y) \ {

[PATCH v1] Match: Support form 1 for scalar signed integer .SAT_ADD

2024-08-05 Thread pan2 . li
From: Pan Li This patch would like to support the form 1 of the scalar signed integer .SAT_ADD. Aka below example: Form 1: #define DEF_SAT_S_ADD_FMT_1(T) \ T __attribute__((noinline))\ sat_s_add_##T##_fmt_1 (T x, T y) \ {

[PATCH v1] RISC-V: Update .SAT_TRUNC dump check due to middle-end change

2024-08-05 Thread pan2 . li
From: Pan Li Due to recent middle-end change, update the .SAT_TRUNC expand dump check from 2 to 4. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/vec_sat_u_trunc-1.c: Adjust asm check times from 2 to 4. Signed-off-by: Pan Li --- .../gcc.target/riscv/rvv/autovec/

[PATCH v2] Vect: Make sure the lhs type of .SAT_TRUNC has its mode precision [PR116202]

2024-08-06 Thread pan2 . li
From: Pan Li The .SAT_TRUNC vect pattern recog is valid when the lhs type has its mode precision. For example as below, QImode with 1 bit precision like _Bool is invalid here. g_12 = (long unsigned int) _2; _13 = MIN_EXPR ; _3 = (_Bool) _13; The above pattern cannot be recog as .SAT_TRUNC (g_1

[PATCH v2] Match: Support form 1 for scalar signed integer .SAT_ADD

2024-08-07 Thread pan2 . li
From: Pan Li This patch would like to support the form 1 of the scalar signed integer .SAT_ADD. Aka below example: Form 1: #define DEF_SAT_S_ADD_FMT_1(T, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_add_##T##_fmt_1 (T x, T y) \ {

[PATCH v1] RISC-V: Bugfix ICE non-vector in TARGET_FUNCTION_VALUE_REGNO_P

2024-04-11 Thread pan2 . li
From: Pan Li This patch would like to fix one ICE when vector is not enabled in hook TARGET_FUNCTION_VALUE_REGNO_P implementation. The vector regno is available if and only if the TARGET_VECTOR is true. The previous implement missed this condition and then result in ICE when rv64gc build option

[committed] RISC-V: Fix Werror=sign-compare in riscv_validate_vector_type

2024-04-12 Thread pan2 . li
From: Pan Li This patch would like to fix the Werror=sign-compare similar to below: gcc/config/riscv/riscv.cc: In function ‘void riscv_validate_vector_type(const_tree, const char*)’: gcc/config/riscv/riscv.cc:5614:23: error: comparison of integer expressions of different signedness: ‘int’ and ‘u

[PATCH v1] RISC-V: Revert RVV wv instructions overlap and xfail tests

2024-04-19 Thread pan2 . li
From: Pan Li The RVV register overlap requires both the dest, and src operands. Thus the rigister filter in constraint cannot cover the fully sematics of the vector register overlap. Thus, revert these overlap patches list and xfail the related test cases. This patch would like to revert *b3b27

[PATCH v1] RISC-V: Add xfail test case for wv insn register overlap

2024-04-19 Thread pan2 . li
From: Pan Li gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr112431-42.c: New test. Signed-off-by: Pan Li --- .../gcc.target/riscv/rvv/base/pr112431-42.c | 30 +++ 1 file changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr1

[PATCH v2] RISC-V: Add xfail test case for wv insn register overlap

2024-04-19 Thread pan2 . li
From: Pan Li We reverted below patch for wv insn overlap, add the related wv insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. b3b2799b872 RISC-V: Support one more overlap for wv instructions gcc/testsuite/ChangeLog: * gcc.ta

[PATCH] RISC-V: Add xfail test case for wv insn highest overlap

2024-04-20 Thread pan2 . li
From: Pan Li We reverted below patch for wv insn overlap, add the related wv insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 7e854b58084 RISC-V: Support highest overlap for wv instructions The below test suites are passed. * The rv6

[PATCH v1] RISC-V: Add xfail test case for incorrect overlap on v0

2024-04-20 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 018ba3ac952 RISC-V: Fix overlap group incorrect overlap on v0 The below test suites are passed. * The r

[PATCH v1] RISC-V: Add xfail test case for highpart register overlap of vx/vf widen

2024-04-20 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. a23415d7572 RISC-V: Support highpart register overlap for widen vx/vf instructions The below test suit

[PATCH v1] RISC-V: Add xfail test case for widening register overlap of vf4/vf8

2024-04-21 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 303195e2a6b RISC-V: Support widening register overlap for vf4/vf8 The below test suites are passed. * T

[PATCH v1] RISC-V: Add xfail test case for highest-number regno ternary overlap

2024-04-21 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 27fde325d64 RISC-V: Support highest-number regno overlap for widen ternary The below test suites are pa

[PATCH v1] RISC-V: Add xfail test case for indexed load overlap with SRC EEW < DEST EEW

2024-04-22 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 4418d55bcd1 RISC-V: Support highpart overlap for indexed load with SRC EEW < DEST EEW The below test s

[PATCH v2] RISC-V: Add xfail test case for indexed load overlap with SRC EEW < DEST EEW

2024-04-22 Thread pan2 . li
From: Pan Li Update in v2: * Add change log to pr112431-34.c. Original log: We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 4418d55bcd1 RISC-V: Support highpart ov

[PATCH v1] RISC-V: Add xfail test case for highpart overlap floating-point widen insn

2024-04-22 Thread pan2 . li
From: Pan Li We reverted below patch for register group overlap, add the related insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. 8614cbb2534 RISC-V: Support highpart overlap for floating-point widen instructions The below test suit

<    1   2   3   4   5   6   7   8   >