From patchwork Mon Jun 26 09:38:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 112820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7356476vqr; Mon, 26 Jun 2023 02:39:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bRdSdaqHLLMcC9ovvY5MlsAeiCkKH/wUX8Rc31YenAuNpZ8TXSZJF7A7ZOxOag9npZl6W X-Received: by 2002:a17:907:628c:b0:96a:63d4:24c5 with SMTP id nd12-20020a170907628c00b0096a63d424c5mr23038567ejc.77.1687772378179; Mon, 26 Jun 2023 02:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687772378; cv=none; d=google.com; s=arc-20160816; b=rfCbwxyBxHMOYaeEDzbpr4+l2eFLe3+IcQocOpcBfQoU7bptXl0AEcKdNAJecuY0sq IlZ66LfCB46f+GXKqbawPiQb29bJcR2tfz/DSEuGJNQuqEhhc3e0QE1J6KchiPXYvSn8 j7/O67fqY+ot0RKMXL5qzPKljyrOXmhCc/PJbb452Hfb5q8db1SPLX1rAGUf5jjdQmHa p/dYSXiKho8P8Td0u5nEtWTDKnGFnEVgt8sWNqniqEZzWEYD+IJ2bFa87cZmO0higl4K IzZjdjZOj5Z4suNFX61MhF+Xg4zFzZZK8CGanqHOu+1Is28jYSq2YRwgvkMQP1RKuCNE dYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=gS/ELffcq5wHgnOLyRmNhDVc1ft4j2HVW0690k7RKTo=; fh=h6UG6PIw2FD/e8JL+9n/VDDoO75bXx4B3jGj5okR2Rw=; b=jRmV79kuudEb6NHpxf4UqNEVnllu7u25/HKNHpBOy7YiGojhtkJoYMZUJt/uH9OOru /FOKwQUFDZ9vB9WFiB1Bg+iOohdizUyI1osz8peUpV3T6uOKLkoKplVFpY/8ZHs5ynY1 BMY5BEpv1e4OuKxrQhL+BxjoKIl7wGq3dHpFHKHkCH2+Djv2RNgIe5+PLb66fIS2IPZ5 S+xG+G66aj2HlGynwduYGTjQYj0bOla4MPLlUm4j9kgu8GovnCRX5HmjzGk5kyYokqHP Ks6Y6BNrk75pJrLlVevycBgU/BcoAHNWnn3rEDCm2wbF5c6GxRqlp9zitMeofwjbnJ7E HjkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ks1-20020a170906f84100b00988c64dd7acsi2670789ejb.620.2023.06.26.02.39.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 02:39:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66486385773F for ; Mon, 26 Jun 2023 09:39:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) by sourceware.org (Postfix) with ESMTPS id CE5303858D35 for ; Mon, 26 Jun 2023 09:38:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE5303858D35 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: bizesmtp65t1687772328toqkbiq6 Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 26 Jun 2023 17:38:47 +0800 (CST) X-QQ-SSF: 01400000000000G0S000000A0000000 X-QQ-FEAT: znfcQSa1hKYfaw+jbu1jxswAJs82EfitAM6htLf8QQK7QKC2pKVtp8Uqo6oDj jKXzeESvzG9l1yEgsYQI8hdBNIoafP+tCarr/nRTDFtixqqzQVy90BtkGkYC+XLBYMI+gvU yzAP6f45Os2OQjVHnN9o9QdddO7zuTbGfWa85iK9MvW9cTXBN1QKwtue1HB/vVRPH/h3MYQ CaHt9abjA7iqCywZrc2p8ep+fGraHDW+x+lwQThnGZmjSBWsDnkY4GUD6CqbQ5aG0xcH7qI blj8yb7jyAeMsWL/zQzcl7uccWcmuZqmTao+nZKic9XyW0VLiv/fmHWtjrMXRPnh0kXyQfS ZsvjsV8Jv2Vo+ChHLyR0tpZc3bf6oGx+EG2nJRmr9k6dbhNLwknj6RavCZ07KGss8ubL4RW X3dPX4bhD+M= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 3380485083386660565 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Ju-Zhe Zhong Subject: [PATCH V2] SCCVN: Add LEN_MASK_STORE and fix LEN_STORE Date: Mon, 26 Jun 2023 17:38:46 +0800 Message-Id: <20230626093846.3006718-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 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_H4, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769757609544187205?= X-GMAIL-MSGID: =?utf-8?q?1769757609544187205?= 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_MAS_STORE and fix LEN_STORE. --- gcc/tree-ssa-sccvn.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 11061a374a2..228ec117ff3 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,11 @@ 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; + if (len) + nunits = tree_to_uhwi (len) + tree_to_shwi (bias); + else + nunits = TYPE_VECTOR_SUBPARTS (vectype); if (mask) { HOST_WIDE_INT start = 0, length = 0; @@ -3373,7 +3388,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 +3404,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