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 8D7C63858409 for ; Sat, 22 Apr 2023 22:09:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D7C63858409 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 33MLGWqD006595 for ; Sat, 22 Apr 2023 15:09:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=70yBC6Tngm2NSXLKMIoxaw8cEQ6mozev4dYAcDbhjWM=; b=NRGnaoZZ2RArEISaPA0kD3xGdMi+J0cELyZpuI3yYHdS2hc/feB1fTI6+BugquwXAWVZ euCC9IRdXyX7hu1b7ck93CpAGIotjZDuBCUmk/4YjqxQeRwDoBgHfARHzC8KR9bpGu0W yUnuiyq0BPLiyNJZBbE0o1ANjcjWUnpkq6ckhm5ZiGZxKum6VOLRYx6fzrwxfEqyrKAb WzRRWuYHmcjomIkCu69bJKAcySXfvU+sO4OYGDLhOemgvAvfjgmcFbWBt5stUB7cdPo8 qW2nlx9CBHPvCxjed2InYkbteZG0WqmeRhze2nCkQ28NWyiE2cxM4XVkdNxuq7yhFmzv FA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q4egjhp9y-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 22 Apr 2023 15:09:44 -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; Sat, 22 Apr 2023 15:09:32 -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; Sat, 22 Apr 2023 15:09:32 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 0FBD03F709B; Sat, 22 Apr 2023 15:09:31 -0700 (PDT) From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 5/6] PHIOPT: Ignore predicates for match-and-simplify phi-opt Date: Sat, 22 Apr 2023 15:09:20 -0700 Message-ID: <20230422220921.452264-6-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230422220921.452264-1-apinski@marvell.com> References: <20230422220921.452264-1-apinski@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: miUDq592cyj5aOHxh6RxQN6-EiZT6nW3 X-Proofpoint-GUID: miUDq592cyj5aOHxh6RxQN6-EiZT6nW3 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-22_15,2023-04-21_01,2023-02-09_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,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: This fixes a missed optimization where early phi-opt would not work when there was predicates. The easiest fix is to change empty_bb_or_one_feeding_into_p to ignore those statements while checking for only feeding statement. Note phi-opt-23.c and phi-opt-24.c still fail as we don't handle diamond form in match_and_simplify phiopt yet. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p): Instead of calling last_and_only_stmt, look for the last statement manually. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Add -fno-ssa-phiopt. --- .../gcc.dg/tree-ssa/ssa-ifcombine-13.c | 4 +++- gcc/tree-ssa-phiopt.cc | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c index 425eb3d6481..7976544c79b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1" } */ +/* Disable phi-opt as it is no longer confused by predicate which had allowed ifcombine to work in the past. + Note this testcase is about ifcombine rather than phi-opt. */ +/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1 -fno-ssa-phiopt" } */ _Bool f1(_Bool a, _Bool b) { diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index cb4d8788b56..ffd6a4e6f35 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -962,9 +962,27 @@ empty_bb_or_one_feeding_into_p (basic_block bb, if (!gimple_seq_empty_p (phi_nodes (bb))) return false; - stmt_to_move = last_and_only_stmt (bb); + gimple_stmt_iterator gsi; + + gsi = gsi_start_nondebug_after_labels_bb (bb); + while (!gsi_end_p (gsi)) + { + gimple *s = gsi_stmt (gsi); + gsi_next_nondebug (&gsi); + /* Skip over Predict and nop statements. */ + if (gimple_code (s) == GIMPLE_PREDICT + || gimple_code (s) == GIMPLE_NOP) + continue; + /* If there is more one statement return false. */ + if (stmt_to_move) + return false; + stmt_to_move = s; + } + + /* The only statement here was a Predict or a nop statement + so return true. */ if (!stmt_to_move) - return false; + return true; if (gimple_vuse (stmt_to_move)) return false; -- 2.39.1