From patchwork Thu Apr 20 01:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 85673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp775762vqo; Wed, 19 Apr 2023 18:07:12 -0700 (PDT) X-Google-Smtp-Source: AKy350bsF7SvUf6VOuMb/0rgo5Te+36VHXEVcgXEdX+HEz2K3kISKZJJYfjahOYshLU39JPrEwoG X-Received: by 2002:a05:6402:160b:b0:506:8e18:9e65 with SMTP id f11-20020a056402160b00b005068e189e65mr6949683edv.9.1681952831924; Wed, 19 Apr 2023 18:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681952831; cv=none; d=google.com; s=arc-20160816; b=XDhcTR58oUFwk8RK8rxyNNQK9U8l9uYjyc+ut3HHLZyiBMzEJ1fVqKJemOyJzQMuW6 Ph4RrVYhwDAeX40xdiXHl5Fd8BqAD8NXkSqfAL56rNp+0ehVxnC/hK5hro7zVj7OgowV fGnRHjpY4oPTXNstgAisTh8TqmQHwehIRZZ0mzINTDrDz1HTCKOr3SMhLpRoTWb5ETmk TAEw5CkkO/kFsmWvIgC3qaJJmTd8M1O7YbbPbpGoE6GgWEJfwZsZBkikpDNLYm5qxHZ2 JRS0YDoW0dMRuNn2/xvAFdOhVKahzNF7IJQQfEwweGLR6DRNt0pJ0tbzNCFrT9n15Gw4 vAmw== 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=PLCl3UGQWtcVlZEbA2W+WbD/wDIrtvQrZiryNUTxMxc=; b=CSztl8/N2hAu7j1/miKQzGAWSngP/QnxUFJ0de2nPEFo+TeKiCWmn0iKKSLYFs4CS9 InFyiTljsBMgkBFxpoZHi5getScH+eHZt93KaOPRSPJecH+o8+OKCLxOAqsuXOwKMjVF 1u5v/oThSMNRQOqOn2lcmaU7D8rJXhnAj8FJ0NYX2eKir66SqQszPRnvwsNKFNhBpuuw 01Y7ep19Ait29AKLg8HiMLo98BC6hImjDquL+PxTx6JWFg16K0MvZF606aRj6iD6v4D4 V2CJkOzrqsj4oyObY66h5aSrZOYxiZNEqZt4DC1FjwuDWfWOLdlj27Qg3vWFNhGVyXrZ VAmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YLdK7cRv; 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 f22-20020a056402161600b0050522a44617si325657edv.436.2023.04.19.18.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 18:07:11 -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=YLdK7cRv; 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 C791E385840C for ; Thu, 20 Apr 2023 01:07:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C791E385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681952830; bh=PLCl3UGQWtcVlZEbA2W+WbD/wDIrtvQrZiryNUTxMxc=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=YLdK7cRv+GVhJtnBveBvwk/Uhp1HE3Te3q2hca1S9H2SX+QyPN3H/OkQLhubDtzJ9 WN5K47pePC6MHfoG+BPqo6riIC6uKbTOYs39f2T/9X7YatLaLrCvB4wPx12DwAsTos 8wt7Aqv1ssA84sGb94TraXUgIkVcnsM2Hf5GKHeA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id AA9DF3858D33 for ; Thu, 20 Apr 2023 01:06:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA9DF3858D33 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33JLJkVY017810 for ; Wed, 19 Apr 2023 18:06:21 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q2917w99k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 19 Apr 2023 18:06:21 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 19 Apr 2023 18:06:19 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 19 Apr 2023 18:06:19 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 628F43F70AF; Wed, 19 Apr 2023 18:06:15 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] PHIOPT: Improve readability of tree_ssa_phiopt_worker Date: Wed, 19 Apr 2023 18:05:35 -0700 Message-ID: <20230420010535.336618-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-GUID: 6jJ1N5e29pKWCx7iKs6mQa6MxnrJ1pt0 X-Proofpoint-ORIG-GUID: 6jJ1N5e29pKWCx7iKs6mQa6MxnrJ1pt0 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-19_16,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, KAM_SHORT, 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?1763655372656786971?= X-GMAIL-MSGID: =?utf-8?q?1763655372656786971?= This small patch just changes around the code slightly to make it easier to understand that the cases were handling diamond shaped BB for both do_store_elim/do_hoist_loads. There is no effect on code output at all since all of the checks are the same still. Note this depends on https://gcc.gnu.org/pipermail/gcc-patches/2023-April/616241.html as that allows this to be done. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Change the code around slightly to move diamond handling for do_store_elim/do_hoist_loads out of the big if/else. --- gcc/tree-ssa-phiopt.cc | 46 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 8c5c8d8c250..d886c88215b 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -175,28 +175,38 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p) std::swap (bb1, bb2); std::swap (e1, e2); } - else if (do_store_elim - && EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest) + else if (EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest) + { + diamond_p = true; + e2 = EDGE_SUCC (bb2, 0); + } + else + continue; + + e1 = EDGE_SUCC (bb1, 0); + + /* Make sure that bb1 is just a fall through. */ + if (!single_succ_p (bb1) + || (e1->flags & EDGE_FALLTHRU) == 0) + continue; + + if (do_store_elim && diamond_p) { - basic_block bb3 = EDGE_SUCC (bb1, 0)->dest; + basic_block bb3 = e1->dest; - if (!single_succ_p (bb1) - || (EDGE_SUCC (bb1, 0)->flags & EDGE_FALLTHRU) == 0 - || !single_succ_p (bb2) - || (EDGE_SUCC (bb2, 0)->flags & EDGE_FALLTHRU) == 0 + if (!single_succ_p (bb2) + || (e2->flags & EDGE_FALLTHRU) == 0 || EDGE_COUNT (bb3->preds) != 2) continue; if (cond_if_else_store_replacement (bb1, bb2, bb3)) cfgchanged = true; continue; } - else if (do_hoist_loads - && EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest) + else if (do_hoist_loads && diamond_p) { - basic_block bb3 = EDGE_SUCC (bb1, 0)->dest; + basic_block bb3 = e1->dest; if (!FLOAT_TYPE_P (TREE_TYPE (gimple_cond_lhs (cond_stmt))) - && single_succ_p (bb1) && single_succ_p (bb2) && single_pred_p (bb1) && single_pred_p (bb2) @@ -209,20 +219,6 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p) hoist_adjacent_loads (bb, bb1, bb2, bb3); continue; } - else if (EDGE_SUCC (bb1, 0)->dest == EDGE_SUCC (bb2, 0)->dest) - { - diamond_p = true; - e2 = EDGE_SUCC (bb2, 0); - } - else - continue; - - e1 = EDGE_SUCC (bb1, 0); - - /* Make sure that bb1 is just a fall through. */ - if (!single_succ_p (bb1) - || (e1->flags & EDGE_FALLTHRU) == 0) - continue; if (do_store_elim && !diamond_p) {