aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPan Li <pan2.li@intel.com>2024-07-27 11:29:42 +0800
committerPan Li <pan2.li@intel.com>2024-07-29 20:18:37 +0800
commit696d8b9bf3f0ea60da0c24361dc5fe559f97ab77 (patch)
tree35e97a91c423b59de765fd085732744df2c965a0 /gcc
parent29b1587e7d34667a1fd63071c1e4f5475cd71026 (diff)
downloadgcc-696d8b9bf3f0ea60da0c24361dc5fe559f97ab77.zip
gcc-696d8b9bf3f0ea60da0c24361dc5fe559f97ab77.tar.gz
gcc-696d8b9bf3f0ea60da0c24361dc5fe559f97ab77.tar.bz2
Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM
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) \ { \ return x >= IMM ? x - IMM : 0; \ } DEF_SAT_U_SUB_IMM_FMT_3(uint64_t, 11) And then we will have gimple before widening-mul as below. Thus, try the .SAT_SUB for the PLUS_EXPR. 4 │ __attribute__((noinline)) 5 │ uint64_t sat_u_sub_imm11_uint64_t_fmt_3 (uint64_t x) 6 │ { 7 │ long unsigned int _1; 8 │ uint64_t _3; 9 │ 10 │ <bb 2> [local count: 1073741824]: 11 │ _1 = MAX_EXPR <x_2(D), 11>; 12 │ _3 = _1 + 18446744073709551605; 13 │ return _3; 14 │ 15 │ } The below test suites are passed for this patch. 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/ChangeLog: * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Try .SAT_SUB for PLUS_EXPR case. Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-math-opts.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index ac86be8..8d96a4c 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -6129,6 +6129,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb)
case PLUS_EXPR:
match_unsigned_saturation_add (&gsi, as_a<gassign *> (stmt));
+ match_unsigned_saturation_sub (&gsi, as_a<gassign *> (stmt));
/* fall-through */
case MINUS_EXPR:
if (!convert_plusminus_to_widen (&gsi, stmt, code))