* [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE
@ 2023-06-26 7:43 juzhe.zhong
2023-06-26 8:14 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: juzhe.zhong @ 2023-06-26 7:43 UTC (permalink / raw)
To: gcc-patches; +Cc: richard.sandiford, rguenther, Ju-Zhe Zhong
From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Hi, Richi.
This patch is adding LEN_MASK_STORE into DSE.
My understanding is LEN_MASK_STORE is predicated by mask and len.
No matter len is constant or not, the ao_ref should be the same as MASK_STORE.
Wheras for LEN_STORE, when len is constant, we use (len - bias), otherwise, it's
the same as MASK_STORE/LEN_MASK_STORE.
Not sure whether I am on the same page with you, feel free to correct me.
Thanks.
gcc/ChangeLog:
* tree-ssa-dse.cc (initialize_ao_ref_for_dse): Add LEN_MASK_STORE and fix LEN_STORE.
(dse_optimize_stmt): Add LEN_MASK_STORE.
---
gcc/tree-ssa-dse.cc | 47 ++++++++++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
index 3c7a2e9992d..f8338037a61 100644
--- a/gcc/tree-ssa-dse.cc
+++ b/gcc/tree-ssa-dse.cc
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa-loop-niter.h"
#include "cfgloop.h"
#include "tree-data-ref.h"
+#include "internal-fn.h"
/* This file implements dead store elimination.
@@ -157,23 +158,36 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write, bool may_def_ok = false)
switch (gimple_call_internal_fn (stmt))
{
case IFN_LEN_STORE:
- ao_ref_init_from_ptr_and_size
- (write, gimple_call_arg (stmt, 0),
- int_const_binop (MINUS_EXPR,
- gimple_call_arg (stmt, 2),
- gimple_call_arg (stmt, 4)));
- return true;
case IFN_MASK_STORE:
- /* We cannot initialize a must-def ao_ref (in all cases) but we
- can provide a may-def variant. */
- if (may_def_ok)
- {
- ao_ref_init_from_ptr_and_size
- (write, gimple_call_arg (stmt, 0),
- TYPE_SIZE_UNIT (TREE_TYPE (gimple_call_arg (stmt, 3))));
- return true;
- }
- break;
+ case IFN_LEN_MASK_STORE:
+ {
+ int stored_value_index
+ = internal_fn_stored_value_index (gimple_call_internal_fn (stmt));
+ if (gimple_call_internal_fn (stmt) == IFN_LEN_STORE)
+ {
+ tree len = gimple_call_arg (stmt, 2);
+ tree bias = gimple_call_arg (stmt, 4);
+ if (tree_fits_uhwi_p (len))
+ {
+ ao_ref_init_from_ptr_and_size (write,
+ gimple_call_arg (stmt, 0),
+ int_const_binop (MINUS_EXPR,
+ len, bias));
+ return true;
+ }
+ }
+ /* We cannot initialize a must-def ao_ref (in all cases) but we
+ can provide a may-def variant. */
+ if (may_def_ok)
+ {
+ ao_ref_init_from_ptr_and_size (
+ write, gimple_call_arg (stmt, 0),
+ TYPE_SIZE_UNIT (
+ TREE_TYPE (gimple_call_arg (stmt, stored_value_index))));
+ return true;
+ }
+ break;
+ }
default:;
}
}
@@ -1502,6 +1516,7 @@ dse_optimize_stmt (function *fun, gimple_stmt_iterator *gsi, sbitmap live_bytes)
{
case IFN_LEN_STORE:
case IFN_MASK_STORE:
+ case IFN_LEN_MASK_STORE:
{
enum dse_store_status store_status;
store_status = dse_classify_store (&ref, stmt, false, live_bytes);
--
2.36.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE
2023-06-26 7:43 [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE juzhe.zhong
@ 2023-06-26 8:14 ` Richard Biener
2023-06-26 14:08 ` Li, Pan2
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-06-26 8:14 UTC (permalink / raw)
To: Ju-Zhe Zhong; +Cc: gcc-patches, richard.sandiford
On Mon, 26 Jun 2023, juzhe.zhong@rivai.ai wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> Hi, Richi.
>
> This patch is adding LEN_MASK_STORE into DSE.
>
> My understanding is LEN_MASK_STORE is predicated by mask and len.
> No matter len is constant or not, the ao_ref should be the same as MASK_STORE.
>
> Wheras for LEN_STORE, when len is constant, we use (len - bias), otherwise, it's
> the same as MASK_STORE/LEN_MASK_STORE.
>
> Not sure whether I am on the same page with you, feel free to correct me.
OK if it passes bootstrap/regtest.
Thanks,
Richard.
> Thanks.
>
> gcc/ChangeLog:
>
> * tree-ssa-dse.cc (initialize_ao_ref_for_dse): Add LEN_MASK_STORE and fix LEN_STORE.
> (dse_optimize_stmt): Add LEN_MASK_STORE.
>
> ---
> gcc/tree-ssa-dse.cc | 47 ++++++++++++++++++++++++++++++---------------
> 1 file changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
> index 3c7a2e9992d..f8338037a61 100644
> --- a/gcc/tree-ssa-dse.cc
> +++ b/gcc/tree-ssa-dse.cc
> @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
> #include "tree-ssa-loop-niter.h"
> #include "cfgloop.h"
> #include "tree-data-ref.h"
> +#include "internal-fn.h"
>
> /* This file implements dead store elimination.
>
> @@ -157,23 +158,36 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write, bool may_def_ok = false)
> switch (gimple_call_internal_fn (stmt))
> {
> case IFN_LEN_STORE:
> - ao_ref_init_from_ptr_and_size
> - (write, gimple_call_arg (stmt, 0),
> - int_const_binop (MINUS_EXPR,
> - gimple_call_arg (stmt, 2),
> - gimple_call_arg (stmt, 4)));
> - return true;
> case IFN_MASK_STORE:
> - /* We cannot initialize a must-def ao_ref (in all cases) but we
> - can provide a may-def variant. */
> - if (may_def_ok)
> - {
> - ao_ref_init_from_ptr_and_size
> - (write, gimple_call_arg (stmt, 0),
> - TYPE_SIZE_UNIT (TREE_TYPE (gimple_call_arg (stmt, 3))));
> - return true;
> - }
> - break;
> + case IFN_LEN_MASK_STORE:
> + {
> + int stored_value_index
> + = internal_fn_stored_value_index (gimple_call_internal_fn (stmt));
> + if (gimple_call_internal_fn (stmt) == IFN_LEN_STORE)
> + {
> + tree len = gimple_call_arg (stmt, 2);
> + tree bias = gimple_call_arg (stmt, 4);
> + if (tree_fits_uhwi_p (len))
> + {
> + ao_ref_init_from_ptr_and_size (write,
> + gimple_call_arg (stmt, 0),
> + int_const_binop (MINUS_EXPR,
> + len, bias));
> + return true;
> + }
> + }
> + /* We cannot initialize a must-def ao_ref (in all cases) but we
> + can provide a may-def variant. */
> + if (may_def_ok)
> + {
> + ao_ref_init_from_ptr_and_size (
> + write, gimple_call_arg (stmt, 0),
> + TYPE_SIZE_UNIT (
> + TREE_TYPE (gimple_call_arg (stmt, stored_value_index))));
> + return true;
> + }
> + break;
> + }
> default:;
> }
> }
> @@ -1502,6 +1516,7 @@ dse_optimize_stmt (function *fun, gimple_stmt_iterator *gsi, sbitmap live_bytes)
> {
> case IFN_LEN_STORE:
> case IFN_MASK_STORE:
> + case IFN_LEN_MASK_STORE:
> {
> enum dse_store_status store_status;
> store_status = dse_classify_store (&ref, stmt, false, live_bytes);
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE
2023-06-26 8:14 ` Richard Biener
@ 2023-06-26 14:08 ` Li, Pan2
0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2023-06-26 14:08 UTC (permalink / raw)
To: Richard Biener, Ju-Zhe Zhong; +Cc: gcc-patches, richard.sandiford
Committed as passed both the bootstrap and regression test, thanks Richard.
Pan
-----Original Message-----
From: Gcc-patches <gcc-patches-bounces+pan2.li=intel.com@gcc.gnu.org> On Behalf Of Richard Biener via Gcc-patches
Sent: Monday, June 26, 2023 4:15 PM
To: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Cc: gcc-patches@gcc.gnu.org; richard.sandiford@arm.com
Subject: Re: [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE
On Mon, 26 Jun 2023, juzhe.zhong@rivai.ai wrote:
> From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
>
> Hi, Richi.
>
> This patch is adding LEN_MASK_STORE into DSE.
>
> My understanding is LEN_MASK_STORE is predicated by mask and len.
> No matter len is constant or not, the ao_ref should be the same as MASK_STORE.
>
> Wheras for LEN_STORE, when len is constant, we use (len - bias), otherwise, it's
> the same as MASK_STORE/LEN_MASK_STORE.
>
> Not sure whether I am on the same page with you, feel free to correct me.
OK if it passes bootstrap/regtest.
Thanks,
Richard.
> Thanks.
>
> gcc/ChangeLog:
>
> * tree-ssa-dse.cc (initialize_ao_ref_for_dse): Add LEN_MASK_STORE and fix LEN_STORE.
> (dse_optimize_stmt): Add LEN_MASK_STORE.
>
> ---
> gcc/tree-ssa-dse.cc | 47 ++++++++++++++++++++++++++++++---------------
> 1 file changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
> index 3c7a2e9992d..f8338037a61 100644
> --- a/gcc/tree-ssa-dse.cc
> +++ b/gcc/tree-ssa-dse.cc
> @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
> #include "tree-ssa-loop-niter.h"
> #include "cfgloop.h"
> #include "tree-data-ref.h"
> +#include "internal-fn.h"
>
> /* This file implements dead store elimination.
>
> @@ -157,23 +158,36 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write, bool may_def_ok = false)
> switch (gimple_call_internal_fn (stmt))
> {
> case IFN_LEN_STORE:
> - ao_ref_init_from_ptr_and_size
> - (write, gimple_call_arg (stmt, 0),
> - int_const_binop (MINUS_EXPR,
> - gimple_call_arg (stmt, 2),
> - gimple_call_arg (stmt, 4)));
> - return true;
> case IFN_MASK_STORE:
> - /* We cannot initialize a must-def ao_ref (in all cases) but we
> - can provide a may-def variant. */
> - if (may_def_ok)
> - {
> - ao_ref_init_from_ptr_and_size
> - (write, gimple_call_arg (stmt, 0),
> - TYPE_SIZE_UNIT (TREE_TYPE (gimple_call_arg (stmt, 3))));
> - return true;
> - }
> - break;
> + case IFN_LEN_MASK_STORE:
> + {
> + int stored_value_index
> + = internal_fn_stored_value_index (gimple_call_internal_fn (stmt));
> + if (gimple_call_internal_fn (stmt) == IFN_LEN_STORE)
> + {
> + tree len = gimple_call_arg (stmt, 2);
> + tree bias = gimple_call_arg (stmt, 4);
> + if (tree_fits_uhwi_p (len))
> + {
> + ao_ref_init_from_ptr_and_size (write,
> + gimple_call_arg (stmt, 0),
> + int_const_binop (MINUS_EXPR,
> + len, bias));
> + return true;
> + }
> + }
> + /* We cannot initialize a must-def ao_ref (in all cases) but we
> + can provide a may-def variant. */
> + if (may_def_ok)
> + {
> + ao_ref_init_from_ptr_and_size (
> + write, gimple_call_arg (stmt, 0),
> + TYPE_SIZE_UNIT (
> + TREE_TYPE (gimple_call_arg (stmt, stored_value_index))));
> + return true;
> + }
> + break;
> + }
> default:;
> }
> }
> @@ -1502,6 +1516,7 @@ dse_optimize_stmt (function *fun, gimple_stmt_iterator *gsi, sbitmap live_bytes)
> {
> case IFN_LEN_STORE:
> case IFN_MASK_STORE:
> + case IFN_LEN_MASK_STORE:
> {
> enum dse_store_status store_status;
> store_status = dse_classify_store (&ref, stmt, false, live_bytes);
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-26 14:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 7:43 [PATCH V3] DSE: Add LEN_MASK_STORE analysis into DSE and fix LEN_STORE juzhe.zhong
2023-06-26 8:14 ` Richard Biener
2023-06-26 14:08 ` 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).