* [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM
@ 2024-07-28 3:25 pan2.li
2024-07-29 9:02 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: pan2.li @ 2024-07-28 3:25 UTC (permalink / raw)
To: gcc-patches
Cc: juzhe.zhong, kito.cheng, richard.guenther, tamar.christina,
jeffreyalaw, rdapp.gcc, Pan Li
From: Pan Li <pan2.li@intel.com>
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>
---
gcc/tree-ssa-math-opts.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index ac86be8eb94..8d96a4c964b 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))
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM
2024-07-28 3:25 [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM pan2.li
@ 2024-07-29 9:02 ` Richard Biener
2024-07-29 12:19 ` Li, Pan2
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2024-07-29 9:02 UTC (permalink / raw)
To: pan2.li
Cc: gcc-patches, juzhe.zhong, kito.cheng, tamar.christina,
jeffreyalaw, rdapp.gcc
On Sun, Jul 28, 2024 at 5:25 AM <pan2.li@intel.com> wrote:
>
> From: Pan Li <pan2.li@intel.com>
>
> 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.
OK
> 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>
> ---
> gcc/tree-ssa-math-opts.cc | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
> index ac86be8eb94..8d96a4c964b 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))
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM
2024-07-29 9:02 ` Richard Biener
@ 2024-07-29 12:19 ` Li, Pan2
0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2024-07-29 12:19 UTC (permalink / raw)
To: Richard Biener
Cc: gcc-patches, juzhe.zhong, kito.cheng, tamar.christina,
jeffreyalaw, rdapp.gcc
> OK
Committed, thanks Richard.
Pan
-----Original Message-----
From: Richard Biener <richard.guenther@gmail.com>
Sent: Monday, July 29, 2024 5:03 PM
To: Li, Pan2 <pan2.li@intel.com>
Cc: gcc-patches@gcc.gnu.org; juzhe.zhong@rivai.ai; kito.cheng@gmail.com; tamar.christina@arm.com; jeffreyalaw@gmail.com; rdapp.gcc@gmail.com
Subject: Re: [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM
On Sun, Jul 28, 2024 at 5:25 AM <pan2.li@intel.com> wrote:
>
> From: Pan Li <pan2.li@intel.com>
>
> 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.
OK
> 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>
> ---
> gcc/tree-ssa-math-opts.cc | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
> index ac86be8eb94..8d96a4c964b 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))
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-29 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-28 3:25 [PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM pan2.li
2024-07-29 9:02 ` Richard Biener
2024-07-29 12:19 ` Li, Pan2
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).