public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: juzhe.zhong@rivai.ai
To: gcc-patches@gcc.gnu.org
Cc: richard.sandiford@arm.com, rguenther@suse.de,
	Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Subject: [PATCH] SSCV: Add LEN_MASK_STORE into SCCVN
Date: Mon, 26 Jun 2023 10:37:35 +0800	[thread overview]
Message-ID: <20230626023735.1013441-1-juzhe.zhong@rivai.ai> (raw)

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


             reply	other threads:[~2023-06-26  2:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  2:37 juzhe.zhong [this message]
2023-06-26  8:11 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230626023735.1013441-1-juzhe.zhong@rivai.ai \
    --to=juzhe.zhong@rivai.ai \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).