]>
git.ipfire.org Git - thirdparty/gcc.git/commit
Match: Support form 4 for unsigned integer .SAT_TRUNC
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) \
{ \
bool not_overflow = x <= (WT)(NT)(-1); \
return ((NT)x) | (NT)((NT)not_overflow - 1); \
}
DEF_SAT_U_TRUC_FMT_4(uint32_t, uint64_t)
Before this patch:
4 │ __attribute__((noinline))
5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x)
6 │ {
7 │ _Bool not_overflow;
8 │ unsigned char _1;
9 │ unsigned char _2;
10 │ unsigned char _3;
11 │ uint8_t _6;
12 │
13 │ ;; basic block 2, loop depth 0
14 │ ;; pred: ENTRY
15 │ not_overflow_5 = x_4(D) <= 255;
16 │ _1 = (unsigned char) x_4(D);
17 │ _2 = (unsigned char) not_overflow_5;
18 │ _3 = _2 + 255;
19 │ _6 = _1 | _3;
20 │ return _6;
21 │ ;; succ: EXIT
22 │
23 │ }
After this patch:
4 │ __attribute__((noinline))
5 │ uint8_t sat_u_truc_uint32_t_to_uint8_t_fmt_4 (uint32_t x)
6 │ {
7 │ uint8_t _6;
8 │
9 │ ;; basic block 2, loop depth 0
10 │ ;; pred: ENTRY
11 │ _6 = .SAT_TRUNC (x_4(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 form 4 for unsigned .SAT_TRUNC matching.
Signed-off-by: Pan Li <pan2.li@intel.com>