From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 5C9223858C39 for ; Tue, 7 Feb 2023 20:20:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9223858C39 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 (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 317IDVeV005847 for ; Tue, 7 Feb 2023 12:20:10 -0800 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=7sFiqsAfKx2O7OW4MFrCQmoyN2jU4eEBO9iBu0aVTSs=; b=WkRZBqaYtaJca5ZHbR5jIHSRRj1lVUtTytxC+/5fYym3/4yl4ERF7DDJzXfmf2RXu+Zq 5pxg13oHOPzCVs1MuRz5ZaB7OMNDspYqck4bDTD84nyQB8rwqx0PpAi2alhnX2J/BKXT YZ3lNvrUtIyx9/ec9+YY4yOaEiYBmHjuzuN/itG2RbgMylOXn+x7Rt98SnOUnMe2jKvJ HV62+OMctfz4IAVEUvtq76JAhR0YVIJO4SRdcj9Rcju4S/lOpn2WE5p5+h2nSmaqhMOq h7LyMGd1vzqJTdq2GsfvbTfAJ3jBjlrYvhneJkJEtPqcJD3OzNZWaHcpoUGnQmXJMdKU fw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nhqrtpmxw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 07 Feb 2023 12:20:10 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 7 Feb 2023 12:20:08 -0800 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.42 via Frontend Transport; Tue, 7 Feb 2023 12:20:08 -0800 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.67]) by maili.marvell.com (Postfix) with ESMTP id EF2753F70A9; Tue, 7 Feb 2023 12:20:06 -0800 (PST) From: Andrew Pinski To: CC: Andrew Pinski Subject: [COMMITTED, GCC 12] Fix PR 108582: ICE due to PHI-OPT removing a still in use ssa_name. Date: Tue, 7 Feb 2023 12:19:59 -0800 Message-ID: <20230207201959.1545413-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-GUID: iMtjcq8fXBk9KXVRd6t8Q9Gk1GV59fmT X-Proofpoint-ORIG-GUID: iMtjcq8fXBk9KXVRd6t8Q9Gk1GV59fmT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-07_11,2023-02-06_03,2022-06-22_01 X-Spam-Status: No, score=-14.5 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 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: This patch adds a check in match_simplify_replacement to make sure the middlebb does not have any phi-nodes as we don't currently move those. This was just a thinko from before. Committed on the GCC 12 branch after a bootstrap/test on x86_64-linux-gnu. PR tree-optimization/108582 gcc/ChangeLog: * tree-ssa-phiopt.cc (match_simplify_replacement): Add check for middlebb to have no phi nodes. gcc/testsuite/ChangeLog: * gcc.dg/pr108582-1.c: New test. (cherry picked from commit 876b3e0514bc8cb2256c44db56255403bedfa52d) --- gcc/testsuite/gcc.dg/pr108582-1.c | 58 +++++++++++++++++++++++++++++++ gcc/tree-ssa-phiopt.cc | 5 +++ 2 files changed, 63 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr108582-1.c diff --git a/gcc/testsuite/gcc.dg/pr108582-1.c b/gcc/testsuite/gcc.dg/pr108582-1.c new file mode 100644 index 00000000000..88c2de369ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr108582-1.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-ccp -fno-tree-dce" } */ + +/* + PHI-OPT via match_simplify_replacement used to transform: + if (_25 != 0) + goto ; [25.00%] + else + goto ; [75.00%] + + [local count: 11649864]: + # iftmp.5_13 = PHI <2(7)> + k_22 = k_11 | iftmp.5_13; + + [local count: 105655256]: + # g_9 = PHI <1(2), 0(8), g_8(7)> + # k_12 = PHI + +into: + + _15 = (int) _25; + _28 = -_15; + _4 = _13 & _28; + _6 = _4 | k_11; + + [local count: 105655256]: + # g_9 = PHI <1(2), g_8(7)> + # k_12 = PHI + +Removing the phi-node/assignment of _13. + + */ + +int a, c, d, e, f; +char b; +int main() { + int g = 1; + char h[1] = {0}; + while (a) { + if (f) { + b = 0; + if (d) + continue; + } + if (a < 1) { + g = 0; + goto L; + } + } + while (c) { + char *j = h; + int k; + L: + if (e && !g) + k |= 2 | (*j < 0); + } + return 0; +} diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 3eda825672c..b8e57bb470e 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -973,6 +973,11 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, if (!single_pred_p (middle_bb)) return false; + /* The middle bb cannot have phi nodes as we don't + move those assignments yet. */ + if (!gimple_seq_empty_p (phi_nodes (middle_bb))) + return false; + stmt_to_move = last_and_only_stmt (middle_bb); if (!stmt_to_move) return false; -- 2.27.0