diff options
author | Pan Li <pan2.li@intel.com> | 2024-10-14 10:03:25 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-10-21 22:12:08 +0800 |
commit | bdbb74e38f30827568ba1224d52f5c86edb5d48c (patch) | |
tree | a5d20b4f159488f42add4e8a67aa86d9dd78554b /gcc | |
parent | 8193e71a07de010c041175e7a8acf62eeae5b336 (diff) | |
download | gcc-bdbb74e38f30827568ba1224d52f5c86edb5d48c.zip gcc-bdbb74e38f30827568ba1224d52f5c86edb5d48c.tar.gz gcc-bdbb74e38f30827568ba1224d52f5c86edb5d48c.tar.bz2 |
Match: Support form 1 for vector signed integer SAT_TRUNC
This patch would like to support the form 1 of the vector signed
integer SAT_TRUNC. Aka below example:
Form 1:
#define DEF_VEC_SAT_S_TRUNC_FMT_1(NT, WT, NT_MIN, NT_MAX) \
void __attribute__((noinline)) \
vec_sat_s_trunc_##NT##_##WT##_fmt_1 (NT *out, WT *in, unsigned limit) \
{ \
unsigned i; \
for (i = 0; i < limit; i++) \
{ \
WT x = in[i]; \
NT trunc = (NT)x; \
out[i] = (WT)NT_MIN <= x && x <= (WT)NT_MAX \
? trunc \
: x < 0 ? NT_MIN : NT_MAX; \
} \
}
DEF_VEC_SAT_S_TRUNC_FMT_1(int32_t, int64_t, INT32_MIN, INT32_MAX)
Before this patch:
48 │ _87 = .SELECT_VL (ivtmp_85, POLY_INT_CST [2, 2]);
49 │ ivtmp_64 = _87 * 8;
50 │ vect_x_14.10_67 = .MASK_LEN_LOAD (vectp_in.8_65, 64B, { -1, ... }, _87, 0);
51 │ vect_trunc_15.21_78 = (vector([2,2]) int) vect_x_14.10_67;
52 │ _61 = VIEW_CONVERT_EXPR<vector([2,2]) unsigned long>(vect_x_14.10_67);
53 │ _32 = _61 >> 63;
54 │ vect_patt_52.16_73 = (vector([2,2]) int) _32;
55 │ vect__46.17_74 = VIEW_CONVERT_EXPR<vector([2,2]) unsigned int>(vect_patt_52.16_73);
56 │ vect__47.18_75 = -vect__46.17_74;
57 │ vect__21.19_76 = VIEW_CONVERT_EXPR<vector([2,2]) int>(vect__47.18_75);
58 │ vect_x.11_68 = VIEW_CONVERT_EXPR<vector([2,2]) unsigned long>(vect_x_14.10_67);
59 │ vect__5.12_69 = vect_x.11_68 + { 2147483648, ... };
60 │ mask__34.13_70 = vect__5.12_69 > { 4294967295, ... };
61 │ _25 = .COND_XOR (mask__34.13_70, vect__21.19_76, { 2147483647, ... }, vect_trunc_15.21_78);
62 │ ivtmp_80 = _87 * 4;
63 │ .MASK_LEN_STORE (vectp_out.23_81, 32B, { -1, ... }, _87, 0, _25);
64 │ vectp_in.8_66 = vectp_in.8_65 + ivtmp_64;
65 │ vectp_out.23_82 = vectp_out.23_81 + ivtmp_80;
66 │ ivtmp_86 = ivtmp_85 - _87;
After this patch:
38 │ _77 = .SELECT_VL (ivtmp_75, POLY_INT_CST [2, 2]);
39 │ ivtmp_65 = _77 * 8;
40 │ vect_x_14.10_68 = .MASK_LEN_LOAD (vectp_in.8_66, 64B, { -1, ... }, _77, 0);
41 │ vect_patt_53.11_69 = .SAT_TRUNC (vect_x_14.10_68);
42 │ ivtmp_70 = _77 * 4;
43 │ .MASK_LEN_STORE (vectp_out.12_71, 32B, { -1, ... }, _77, 0, vect_patt_53.11_69);
44 │ vectp_in.8_67 = vectp_in.8_66 + ivtmp_65;
45 │ vectp_out.12_72 = vectp_out.12_71 + ivtmp_70;
46 │ ivtmp_76 = ivtmp_75 - _77;
The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.
gcc/ChangeLog:
* match.pd: Refine matching for vector signed SAT_TRUNC form 1.
Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/match.pd | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 12d81fc..ec2038d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3482,7 +3482,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) SAT_S_TRUNC(X) = (unsigned)X + NT_MAX + 1 > Unsigned_MAX ? (NT)X. */ (match (signed_integer_sat_trunc @0) (cond^ (gt (plus:c (convert@4 @0) INTEGER_CST@1) INTEGER_CST@2) - (bit_xor:c (negate (convert (lt @0 integer_zerop))) INTEGER_CST@3) + (bit_xor:c (nop_convert? + (negate (nop_convert? (convert (lt @0 integer_zerop))))) + INTEGER_CST@3) (convert @0)) (if (INTEGRAL_TYPE_P (type) && !TYPE_UNSIGNED (type) && !TYPE_UNSIGNED (TREE_TYPE (@0)) && TYPE_UNSIGNED (TREE_TYPE (@4))) |