From patchwork Tue Apr 18 19:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 85054 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3075988vqo; Tue, 18 Apr 2023 12:22:50 -0700 (PDT) X-Google-Smtp-Source: AKy350YAWAq570OR8PB3aLm39NeAnFG/fNkiQr8OvTu6SZ7oGmVXGOW4VIh4LEs4V0mqw3CTH8xU X-Received: by 2002:a50:fb9a:0:b0:506:a7a4:88a9 with SMTP id e26-20020a50fb9a000000b00506a7a488a9mr3304198edq.4.1681845770753; Tue, 18 Apr 2023 12:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681845770; cv=none; d=google.com; s=arc-20160816; b=WGJUzQ2E2v142//4Py8bnv9GmoS8aNzTMieETmNq1ICjL9hVSMIhEq1AR0NYGtqyiA 3SKx6S2X4rRXPLYG68odxwL58bbK/EHi2j+TJmZXG1Y7w+Ewd2RUj3PFneTcXXJMhg4L aa4BlfsFTyU7UdNZW0Dm1b/K1UARU9hQlst7l3KGdQY2Lc+zWVM53UD5ey3vdqcq9FsH ny9th+r4aCW+k3MhSWRLzr4dSJ3wt7aRQ7gpziPVOtnCjKZaTrP8S1cFsb2BcgJwGl++ VwIvDiRJSOH5xo9o4RdvOBu2/s3qMGonbKRkBAbxfKCA/QK/AwzzT8udn11v7Cz3achb DTFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Z7gZV8i7DucFazXQ7I9UOeEhaWclZRTHp0ZA1lW/QUA=; b=nKu4lhaAEfv6oZ+WkAZ3LTbPAPcx7eabhDD/az57VFhmwfWWum29ZegXvLir0b19IP B7QDJSyCOr8+Qkq7wV5+VST9KJtPFAXHV5dGmhC3uz5TWsi2a72vbqSeqUrdsv0fl03m Bz8F63gdHST8OMeIYCmgtDtrl3/YUUVRlL0xx33tIiweWjSmVYdRJKgfKvT/2j3jE5/H bzg+RJKLZHrr6Zudv/x2AfYprBU7sMAtlfpCwbalnEF36049SkPUrHDDBhoGQQcK/lHK kP5Fd1BN74bEbeul9Wiqe7gkfMzJEhZCamfz9bN/pmiY9sA/1CLpDnu1Ouiisd1K/wSd qnMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qyrMj1E2; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f12-20020a056402004c00b005049c85875esi12251767edu.659.2023.04.18.12.22.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 12:22:50 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qyrMj1E2; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB78B3858C60 for ; Tue, 18 Apr 2023 19:22:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB78B3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681845769; bh=Z7gZV8i7DucFazXQ7I9UOeEhaWclZRTHp0ZA1lW/QUA=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qyrMj1E2pAwvOY5CrgMa7Flg4Dq39Fnlyn32IdYQLgAmroZNvgyPFI191O+O6Nwdk agog/JGoMxQ+0klaRrCo81+MQbMf9qji9IZsnQg2dfIwQ4kVuzzFCmAUqbdsuCCGUP bfjXKh0aRLgia/CjcxOFWAIxWBLWnbz/Dm4NPd5s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id A35673858D1E for ; Tue, 18 Apr 2023 19:22:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A35673858D1E Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33IEnKc4016673 for ; Tue, 18 Apr 2023 12:22:02 -0700 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q1hf3xnsq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 18 Apr 2023 12:22:01 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 18 Apr 2023 12:22:00 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 18 Apr 2023 12:22:00 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id F236E5B6921; Tue, 18 Apr 2023 12:21:59 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] PHIOPT: Move tree_ssa_cs_elim into pass_cselim::execute. Date: Tue, 18 Apr 2023 12:21:36 -0700 Message-ID: <20230418192136.286589-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: HygLcX17tr_9gkLhh_PaBw3jc7ZEFam7 X-Proofpoint-GUID: HygLcX17tr_9gkLhh_PaBw3jc7ZEFam7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-18_14,2023-04-18_01,2023-02-09_01 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: , X-Patchwork-Original-From: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: Andrew Pinski 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?1763543110851255975?= X-GMAIL-MSGID: =?utf-8?q?1763543110851255975?= This moves around the code for tree_ssa_cs_elim slightly improving code readability and removing declarations that are no longer needed. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Remove declaration. (make_pass_phiopt): Make execute out of line. (tree_ssa_cs_elim): Move code into ... (pass_cselim::execute): here. --- gcc/tree-ssa-phiopt.cc | 118 ++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 61 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 616b5778602..945507be11e 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -55,7 +55,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-propagate.h" #include "tree-ssa-dce.h" -static unsigned int tree_ssa_phiopt_worker (bool, bool, bool); static bool two_value_replacement (basic_block, basic_block, edge, gphi *, tree, tree); static bool match_simplify_replacement (basic_block, basic_block, @@ -78,62 +77,6 @@ static hash_set * get_non_trapping (); static void hoist_adjacent_loads (basic_block, basic_block, basic_block, basic_block); -/* This pass tries to transform conditional stores into unconditional - ones, enabling further simplifications with the simpler then and else - blocks. In particular it replaces this: - - bb0: - if (cond) goto bb2; else goto bb1; - bb1: - *p = RHS; - bb2: - - with - - bb0: - if (cond) goto bb1; else goto bb2; - bb1: - condtmp' = *p; - bb2: - condtmp = PHI - *p = condtmp; - - This transformation can only be done under several constraints, - documented below. It also replaces: - - bb0: - if (cond) goto bb2; else goto bb1; - bb1: - *p = RHS1; - goto bb3; - bb2: - *p = RHS2; - bb3: - - with - - bb0: - if (cond) goto bb3; else goto bb1; - bb1: - bb3: - condtmp = PHI - *p = condtmp; */ - -static unsigned int -tree_ssa_cs_elim (void) -{ - unsigned todo; - /* ??? We are not interested in loop related info, but the following - will create it, ICEing as we didn't init loops with pre-headers. - An interfacing issue of find_data_references_in_bb. */ - loop_optimizer_init (LOOPS_NORMAL); - scev_initialize (); - todo = tree_ssa_phiopt_worker (true, false, false); - scev_finalize (); - loop_optimizer_finalize (); - return todo; -} - /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */ static gphi * @@ -4278,6 +4221,47 @@ make_pass_phiopt (gcc::context *ctxt) return new pass_phiopt (ctxt); } +/* This pass tries to transform conditional stores into unconditional + ones, enabling further simplifications with the simpler then and else + blocks. In particular it replaces this: + + bb0: + if (cond) goto bb2; else goto bb1; + bb1: + *p = RHS; + bb2: + + with + + bb0: + if (cond) goto bb1; else goto bb2; + bb1: + condtmp' = *p; + bb2: + condtmp = PHI + *p = condtmp; + + This transformation can only be done under several constraints, + documented below. It also replaces: + + bb0: + if (cond) goto bb2; else goto bb1; + bb1: + *p = RHS1; + goto bb3; + bb2: + *p = RHS2; + bb3: + + with + + bb0: + if (cond) goto bb3; else goto bb1; + bb1: + bb3: + condtmp = PHI + *p = condtmp; */ + namespace { const pass_data pass_data_cselim = @@ -4302,10 +4286,7 @@ public: /* opt_pass methods: */ bool gate (function *) final override { return flag_tree_cselim; } - unsigned int execute (function *) final override - { - return tree_ssa_cs_elim (); - } + unsigned int execute (function *) final override; }; // class pass_cselim @@ -4316,3 +4297,18 @@ make_pass_cselim (gcc::context *ctxt) { return new pass_cselim (ctxt); } + +unsigned int +pass_cselim::execute (function *) +{ + unsigned todo; + /* ??? We are not interested in loop related info, but the following + will create it, ICEing as we didn't init loops with pre-headers. + An interfacing issue of find_data_references_in_bb. */ + loop_optimizer_init (LOOPS_NORMAL); + scev_initialize (); + todo = tree_ssa_phiopt_worker (true, false, false); + scev_finalize (); + loop_optimizer_finalize (); + return todo; +}