public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] SSCV: Add LEN_MASK_STORE into SCCVN
@ 2023-06-26  2:37 juzhe.zhong
  2023-06-26  8:11 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: juzhe.zhong @ 2023-06-26  2:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.sandiford, rguenther, Ju-Zhe Zhong

From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>

Hi, this patch is to add LEN_MASK_STORE into SCCVN.

LEN_MASK_STORE is predicated by both len and mask together.
My understanding is that LEN_MASK_STORE has same rhs_off and offset as MASK_STORE.
The size = MIN (length (deduced from mask), (len + bias)).

Not sure my understanding it correct or no. 
Hope experts (both Richard && Richi) can correct me if I am wrong.

Thanks.

gcc/ChangeLog:

        * tree-ssa-sccvn.cc (vn_reference_lookup_3): Add LEN_MASK_STORE.

---
 gcc/tree-ssa-sccvn.cc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 11061a374a2..d1629800705 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -3304,6 +3304,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
 	  if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias))
 	    return (void *)-1;
 	  break;
+	case IFN_LEN_MASK_STORE:
+	  len = gimple_call_arg (call, 2);
+	  bias = gimple_call_arg (call, 5);
+	  if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias))
+	    return (void *)-1;
+	  mask = gimple_call_arg (call, internal_fn_mask_index (fn));
+	  mask = vn_valueize (mask);
+	  if (TREE_CODE (mask) != VECTOR_CST)
+	    return (void *)-1;
+	  break;
 	default:
 	  return (void *)-1;
 	}
@@ -3379,6 +3389,13 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
 		      pd.rhs_off = start;
 		      pd.offset = offset2i + start;
 		      pd.size = length;
+		      if (fn == IFN_LEN_MASK_STORE)
+			{
+			  HOST_WIDE_INT len_bitsize
+			    = (tree_to_uhwi (len) + tree_to_shwi (bias))
+			      * BITS_PER_UNIT;
+			  pd.size = length > len_bitsize ? length : len_bitsize;
+			}
 		      if (ranges_known_overlap_p (offset, maxsize,
 						  pd.offset, pd.size))
 			return data->push_partial_def (pd, set, set,
-- 
2.36.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] SSCV: Add LEN_MASK_STORE into SCCVN
  2023-06-26  2:37 [PATCH] SSCV: Add LEN_MASK_STORE into SCCVN juzhe.zhong
@ 2023-06-26  8:11 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-06-26  8:11 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, this patch is to add LEN_MASK_STORE into SCCVN.
> 
> LEN_MASK_STORE is predicated by both len and mask together.
> My understanding is that LEN_MASK_STORE has same rhs_off and offset as MASK_STORE.
> The size = MIN (length (deduced from mask), (len + bias)).
> 
> Not sure my understanding it correct or no. 
> Hope experts (both Richard && Richi) can correct me if I am wrong.
> 
> Thanks.
> 
> gcc/ChangeLog:
> 
>         * tree-ssa-sccvn.cc (vn_reference_lookup_3): Add LEN_MASK_STORE.
> 
> ---
>  gcc/tree-ssa-sccvn.cc | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
> index 11061a374a2..d1629800705 100644
> --- a/gcc/tree-ssa-sccvn.cc
> +++ b/gcc/tree-ssa-sccvn.cc
> @@ -3304,6 +3304,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
>  	  if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias))
>  	    return (void *)-1;
>  	  break;
> +	case IFN_LEN_MASK_STORE:
> +	  len = gimple_call_arg (call, 2);
> +	  bias = gimple_call_arg (call, 5);
> +	  if (!tree_fits_uhwi_p (len) || !tree_fits_shwi_p (bias))
> +	    return (void *)-1;
> +	  mask = gimple_call_arg (call, internal_fn_mask_index (fn));
> +	  mask = vn_valueize (mask);
> +	  if (TREE_CODE (mask) != VECTOR_CST)
> +	    return (void *)-1;
> +	  break;
>  	default:
>  	  return (void *)-1;
>  	}
> @@ -3379,6 +3389,13 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
>  		      pd.rhs_off = start;
>  		      pd.offset = offset2i + start;
>  		      pd.size = length;
> +		      if (fn == IFN_LEN_MASK_STORE)

can you use if (len != 0) here?

> +			{
> +			  HOST_WIDE_INT len_bitsize
> +			    = (tree_to_uhwi (len) + tree_to_shwi (bias))
> +			      * BITS_PER_UNIT;
> +			  pd.size = length > len_bitsize ? length : len_bitsize;
> +			}
>  		      if (ranges_known_overlap_p (offset, maxsize,
>  						  pd.offset, pd.size))
>  			return data->push_partial_def (pd, set, set,

the code continues with

                      mask_idx++;
                    }
                  while (known_lt (mask_idx, TYPE_VECTOR_SUBPARTS 
(vectype)));

it might be nicer to store TYPE_VECTOR_SUBPARTS in a variable and
trim that on 'len' instead?

Thanks,
Richard.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-26  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26  2:37 [PATCH] SSCV: Add LEN_MASK_STORE into SCCVN juzhe.zhong
2023-06-26  8:11 ` Richard Biener

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).