From patchwork Mon Jun 26 01:54:43 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: 112695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7190303vqr; Sun, 25 Jun 2023 18:55:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49RjCXPMASCRAim+zYSOliFlyt3Fw4kvrRqDKYX5LQu8m5RoHyX0I500SwBkOQMnn3QPdM X-Received: by 2002:a05:6402:27cb:b0:514:94be:323c with SMTP id c11-20020a05640227cb00b0051494be323cmr26260576ede.10.1687744534892; Sun, 25 Jun 2023 18:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687744534; cv=none; d=google.com; s=arc-20160816; b=H+BRUUV3vRRAoHSfXtabALG5a/33Q6bl+HmGY49IICo+MiTxgOtm3YQYDjWleC/+G9 t3J8wVmd3jiSMLqKERPaPT+NAH4o6Qki+DYe3eqEC93ercKwyujC7DZZvS1PG5XjWSLW RyI0duXPeMT0pwfwi7i+6mMXKEQZOMexLi2GNxXJq5UThLdTlYKfRfrH7AH1JmmgVgSh fr0aqWHZz5QwbAeOYG9Dz9RGzXOX5FfF1CmVbMjM9iSfv2XvEEvIP0k6iIjeMdpIVJtH H/8vxVm+9uKdkF0rZQzpx6Az/vNMiTOmE2OpjOMimAuDrJYlD+ezIcetUC1EjOlaRQfs DKpw== 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=8bZz3ZLR24btStg8GQf15PF7NQjjaqP7bnOHLMiWWLg=; fh=h6UG6PIw2FD/e8JL+9n/VDDoO75bXx4B3jGj5okR2Rw=; b=D4Sxhnb9MGZfp91VZknjF+/LvllXJmsa9AiACXHaJ6v1XAbPTdY2IEWQ4ozWUjejRA 8bl0RTGutXyuFldqkPAZjtIuOzLsdyVmp9zwwuuLwjqQIe+DjLH74G2BsNXPk6Tt2Tox +rRbN794LwK1GKT5CqScq8HO/3o2eXHnMlBHR67KEYrs2w2n8EDzif+/7yLkKwtAqg9n e+/NDLCFQ0ZwI75hLHTy7wRUenUbWNF12oRn3Bup7T62XNjyVFlfdZd/rF+JKvfnBnjc NwfHXzdaqkD7VwjbT/kO/8O1ewQxmSjGuOcsBR3jd0wx8swyK1YnIitxq4ykTCDAWndL 1U5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i16-20020aa7dd10000000b0051d8d026b84si1628226edv.596.2023.06.25.18.55.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 18:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 4639E3858412 for ; Mon, 26 Jun 2023 01:55:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by sourceware.org (Postfix) with ESMTPS id B5EFB3858D20 for ; Mon, 26 Jun 2023 01:54:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5EFB3858D20 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: bizesmtp76t1687744486tr43j6xq Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 26 Jun 2023 09:54:44 +0800 (CST) X-QQ-SSF: 01400000000000G0S000000A0000000 X-QQ-FEAT: lO87fmWkX3F/BC4XJ1/MxRlGKKgTKHmtBZV2H5+nF9nzB5my41rTu9LT47cIf v3eO+QeEyDjhAmgGyiRmbZh5Oub7hD6iGrCTrwPgDUwy7g+r12M/wQmML4SeJRWpKmnQSKX XBMuUKk+Hd7ndpFY5h0XLgqmSNvSkvErUR5Ksi/su0FjTB2NlsTQdGoiDzTxLq6+J8t0C2S bfcuytQpmi/fQKfPcYZtX4c+8ORuQ+Fn70r3hIBYuqvo44Ofk3yzSWMilZpNVST35A0FQka 1titKtZkyJUzluryEFh8/pk2o0/C6r7os2ataIloj72SQ49+L3+WBip5/R7o5Mwq76hL7CB +w6n5CP5j2YIPGf9iDa+DUGtSBZYsLsRnESz/OqXseAq1XbgS0bUvf+3VTzPfFaqbKetK0k X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10337231032182986574 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] DSE: Add LEN_MASK_STORE analysis into DSE Date: Mon, 26 Jun 2023 09:54:43 +0800 Message-Id: <20230626015443.89052-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?1769728413156070088?= X-GMAIL-MSGID: =?utf-8?q?1769728413156070088?= From: Ju-Zhe Zhong gcc/ChangeLog: * tree-ssa-dse.cc (initialize_ao_ref_for_dse): Add LEN_MASK_STORE. (dse_optimize_stmt): Ditto. --- gcc/tree-ssa-dse.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc index 3c7a2e9992d..b39edd259ab 100644 --- a/gcc/tree-ssa-dse.cc +++ b/gcc/tree-ssa-dse.cc @@ -174,6 +174,32 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write, bool may_def_ok = false) return true; } break; + case IFN_LEN_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) + { + /* LEN_MASK_STORE is predicated by both mask and len. + We only create ao_ref which is same as MASK_STORE when + (len + bias) is a known INTEGER_CST/POLY_CST value > 0. + Otherwise, we create ao_ref with unknown size. */ + tree ele_bytesize + = TYPE_SIZE_UNIT (TREE_TYPE (gimple_call_arg (stmt, 3))); + tree ele_num + = int_const_binop (PLUS_EXPR, + gimple_call_arg (stmt, 2), + gimple_call_arg (stmt, 5)); + tree actual_bytesize = NULL_TREE; + if (ele_num && poly_int_tree_p (ele_num) + && known_gt (tree_to_poly_uint64 (ele_num), 0U)) + actual_bytesize = ele_bytesize; + ao_ref_init_from_ptr_and_size (write, gimple_call_arg (stmt, 0), + actual_bytesize); + return true; + } + break; + } default:; } } @@ -1502,6 +1528,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);