From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by sourceware.org (Postfix) with ESMTPS id A4A703858D1E for ; Mon, 26 Jun 2023 12:04:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4A703858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp91t1687781072tbq5ghz6 Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 26 Jun 2023 20:04:30 +0800 (CST) X-QQ-SSF: 01400000000000G0S000000A0000000 X-QQ-FEAT: dKvkn8qoLrFXgqyj14CFtMFB+FzMh3Zvbk7elFaBf0ozWWnXrDQDrhnqu5coi q4wDlLb3gDXWF8CdKItnp1GJUO5U7Be/nnKLhPPmcnTBO0qorq+LGwhqE8Awuf4yCRF/QbP WrWCb8dRPdySpOzTJzoBX3kbiEAe2o2FaiV1wJdAux+N/7WLzDs0DZ8ofGTQKobeGD0ac0c Aso5uw6mHRtyz0sSIZRCP9rHhyEt9Qw8Hzr1OOLmH9TYAZZYf9aw/2tXEc+/7L4ADskXNnK YReF90J2KeOYEMhHoJ3tHlDI+pGrv/ohGv5w8HDrUVFGI0e18M7halnXNSfp6zXFrmpPVGm xDp7BCPOQJk/+HbStYG+PehUGa6zfkXdLXLSYEMlGoO627fQWegNucptFCasGDW5mujTJ8u 0FY50zItVSk= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 7600952507399188680 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Ju-Zhe Zhong Subject: [PATCH V3] SCCVN: Add LEN_MASK_STORE and fix LEN_STORE Date: Mon, 26 Jun 2023 20:04:29 +0800 Message-Id: <20230626120429.3403256-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Ju-Zhe Zhong Hi, Richi. It seems that we use nunits which is len + bias to iterate then we can simplify the codes. Also, I fixed behavior of len_store, Before this patch: (len - bias) * BITS_PER_UNIT After this patch: (len + bias) * BITS_PER_UNIT gcc/ChangeLog: * tree-ssa-sccvn.cc (vn_reference_lookup_3): Add LEN_MASK_STORE and fix LEN_STORE. --- gcc/tree-ssa-sccvn.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 11061a374a2..d66e75460ed 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; } @@ -3344,6 +3354,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, tree vectype = TREE_TYPE (def_rhs); unsigned HOST_WIDE_INT elsz = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (vectype))); + poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype); + if (len) + { + /* Since the following while condition known_lt + (mask_idx, nunits) will exit the while loop + when mask_idx > nunits.coeffs[0], we pick the + MIN (nunits.coeffs[0], len + bias). */ + nunits = MIN (nunits.coeffs[0], + tree_to_uhwi (len) + tree_to_shwi (bias)); + } if (mask) { HOST_WIDE_INT start = 0, length = 0; @@ -3373,7 +3393,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, length += elsz; mask_idx++; } - while (known_lt (mask_idx, TYPE_VECTOR_SUBPARTS (vectype))); + while (known_lt (mask_idx, nunits)); if (length != 0) { pd.rhs_off = start; @@ -3389,7 +3409,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, { pd.offset = offset2i; pd.size = (tree_to_uhwi (len) - + -tree_to_shwi (bias)) * BITS_PER_UNIT; + + tree_to_shwi (bias)) * BITS_PER_UNIT; if (BYTES_BIG_ENDIAN) pd.rhs_off = pd.size - tree_to_uhwi (TYPE_SIZE (vectype)); else -- 2.36.3