diff options
author | Pan Li <pan2.li@intel.com> | 2024-09-03 15:39:16 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-09-10 15:44:36 +0800 |
commit | a7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8 (patch) | |
tree | 47bbba769b8cfa2e2141aa75a865e4a214809740 /gcc/tree-vect-patterns.cc | |
parent | 73dc46f47be6157eaebc3fd089f57fab2304bb01 (diff) | |
download | gcc-a7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8.zip gcc-a7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8.tar.gz gcc-a7eaf7d5edb194bae0d7d9bc3d20bb5730be57d8.tar.bz2 |
Match: Support form 2 for scalar signed integer .SAT_ADD
This patch would like to support the form 2 of the scalar signed
integer .SAT_ADD. Aka below example:
Form 2:
#define DEF_SAT_S_ADD_FMT_2(T, UT, MIN, MAX) \
T __attribute__((noinline)) \
sat_s_add_##T##_fmt_2 (T x, T y) \
{ \
T sum = (UT)x + (UT)y; \
\
if ((x ^ y) < 0 || (sum ^ x) >= 0) \
return sum; \
\
return x < 0 ? MIN : MAX; \
}
DEF_SAT_S_ADD_FMT_2(int8_t, uint8_t, INT8_MIN, INT8_MAX)
We can tell the difference before and after this patch if backend
implemented the ssadd<m>3 pattern similar as below.
Before this patch:
4 │ __attribute__((noinline))
5 │ int8_t sat_s_add_int8_t_fmt_2 (int8_t x, int8_t y)
6 │ {
7 │ int8_t sum;
8 │ unsigned char x.0_1;
9 │ unsigned char y.1_2;
10 │ unsigned char _3;
11 │ signed char _4;
12 │ signed char _5;
13 │ int8_t _6;
14 │ _Bool _11;
15 │ signed char _12;
16 │ signed char _13;
17 │ signed char _14;
18 │ signed char _22;
19 │ signed char _23;
20 │
21 │ ;; basic block 2, loop depth 0
22 │ ;; pred: ENTRY
23 │ x.0_1 = (unsigned char) x_7(D);
24 │ y.1_2 = (unsigned char) y_8(D);
25 │ _3 = x.0_1 + y.1_2;
26 │ sum_9 = (int8_t) _3;
27 │ _4 = x_7(D) ^ y_8(D);
28 │ _5 = x_7(D) ^ sum_9;
29 │ _23 = ~_4;
30 │ _22 = _5 & _23;
31 │ if (_22 >= 0)
32 │ goto <bb 4>; [42.57%]
33 │ else
34 │ goto <bb 3>; [57.43%]
35 │ ;; succ: 4
36 │ ;; 3
37 │
38 │ ;; basic block 3, loop depth 0
39 │ ;; pred: 2
40 │ _11 = x_7(D) < 0;
41 │ _12 = (signed char) _11;
42 │ _13 = -_12;
43 │ _14 = _13 ^ 127;
44 │ ;; succ: 4
45 │
46 │ ;; basic block 4, loop depth 0
47 │ ;; pred: 2
48 │ ;; 3
49 │ # _6 = PHI <sum_9(2), _14(3)>
50 │ return _6;
51 │ ;; succ: EXIT
52 │
53 │ }
After this patch:
4 │ __attribute__((noinline))
5 │ int8_t sat_s_add_int8_t_fmt_2 (int8_t x, int8_t y)
6 │ {
7 │ int8_t _6;
8 │
9 │ ;; basic block 2, loop depth 0
10 │ ;; pred: ENTRY
11 │ _6 = .SAT_ADD (x_7(D), y_8(D)); [tail call]
12 │ return _6;
13 │ ;; succ: EXIT
14 │
15 │ }
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: Add the form 2 of signed .SAT_ADD matching.
Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
0 files changed, 0 insertions, 0 deletions