From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id 806B93858D28 for ; Mon, 1 May 2023 16:37:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 806B93858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com 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 33UNOEQw006480 for ; Mon, 1 May 2023 09:37:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=txF9SpFAstquBnfFFnMHfIMkMuh1qnftmhpNluODWdw=; b=TBeltkv0TwPRsSmnE+CwFQZoSF37RCrbYfDf5deNxIk1HRF/BvG+wAAMaRl9rFQKmAjL iRePszv5m3fOPSBPN9r0ZOxOTBuvQX48mnDg+p8wwa39fYZdJqmFgXDEZt9/ymIQEFEQ B+K4S1NtbQXbdEDhRlrgf7PpZoKBVADsUDLFZR4/pMb/HlhFHkSmryvsmdROjo9QjNtG nDRoHi6SdCt0Fxr9JI4vqSz8Doi1GyzRYLvGF9lGpo03G9t2rspYbAoEhvrLFhwjP89u OQ8d0JnBKTaZStePwj9ztYSldVA57byglY6w8+9c+QhXbTliabAyoiQb88kGkL9J16lM Yg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q90kry010-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 01 May 2023 09:37:11 -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; Mon, 1 May 2023 09:37:09 -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; Mon, 1 May 2023 09:37:09 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.76.242.112]) by maili.marvell.com (Postfix) with ESMTP id 24FF23F7057; Mon, 1 May 2023 09:37:09 -0700 (PDT) From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] PHIOPT: Update comment about what the pass now does Date: Mon, 1 May 2023 09:37:00 -0700 Message-ID: <20230501163700.797083-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: tZ1qieWSOzt5IRvJPmsup020PfnoDRq1 X-Proofpoint-GUID: tZ1qieWSOzt5IRvJPmsup020PfnoDRq1 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-05-01_09,2023-04-27_01,2023-02-09_01 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SCC_5_SHORT_WORD_LINES,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 List-Id: I noticed I didn't update the comment about how the pass works after I initially added match_simplify_replacement. Anyways this updates the comment to be the current state of the pass. OK? gcc/ChangeLog: * tree-ssa-phiopt.cc: Update comment about how the transformation are implemented. --- gcc/tree-ssa-phiopt.cc | 67 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 147e8f186ce..47ca354fabe 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -3730,31 +3730,55 @@ gate_hoist_loads (void) } /* This pass tries to replaces an if-then-else block with an - assignment. We have four kinds of transformations. Some of these - transformations are also performed by the ifcvt RTL optimizer. + assignment. We have different kinds of transformations. + Some of these transformations are also performed by the ifcvt + RTL optimizer. - Conditional Replacement + PHI-OPT using Match-and-simplify infrastructure ----------------------- - This transformation, implemented in match_simplify_replacement, - replaces + The PHI-OPT pass will try to use match-and-simplify infrastructure + (gimple_simplify) to do transformations. This is implemented in + match_simplify_replacement. + The way it works is it replaces: bb0: if (cond) goto bb2; else goto bb1; bb1: bb2: - x = PHI <0 (bb1), 1 (bb0), ...>; + x = PHI ; - with + with a statement if it gets simplified from `cond ? b : a`. bb0: - x' = cond; - goto bb2; + x1 = cond ? b : a; bb2: - x = PHI ; + x = PHI ; + Bb1 might be removed as it becomes unreachable when doing the replacement. + Though bb1 does not have to be considered a forwarding basic block from bb0. + + Will try to see if `(!cond) ? a : b` gets simplified (iff !cond simplifies); + this is done not to have an explosion of patterns in match.pd. + Note bb1 does not need to be completely empty, it can contain + one statement which is known not to trap. - We remove bb1 as it becomes unreachable. This occurs often due to - gimplification of conditionals. + It also can handle the case where we have two forwarding bbs (diamond): + bb0: + if (cond) goto bb2; else goto bb1; + bb1: goto bb3; + bb2: goto bb3; + bb3: + x = PHI ; + And that is replaced with a statement if it is simplified + from `cond ? b : a`. + Again bb1 and bb2 does not have to be completely empty but + each can contain one statement which is known not to trap. + But in this case bb1/bb2 can only be forwarding basic blocks. + + This fully replaces the old "Conditional Replacement", + "ABS Replacement" transformations as they are now + implmeneted in match.pd. + Some parts of the "MIN/MAX Replacement" are re-implemented in match.pd. Value Replacement ----------------- @@ -3796,25 +3820,6 @@ gate_hoist_loads (void) t3 = t1 & t2; x = a; - ABS Replacement - --------------- - - This transformation, implemented in match_simplify_replacement, replaces - - bb0: - if (a >= 0) goto bb2; else goto bb1; - bb1: - x = -a; - bb2: - x = PHI ; - - with - - bb0: - x' = ABS_EXPR< a >; - bb2: - x = PHI ; - MIN/MAX Replacement ------------------- -- 2.31.1