From patchwork Wed Nov 17 07:46:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1556106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ttcNH4vy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HvFQ83z2pz9s1l for ; Wed, 17 Nov 2021 18:47:27 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7830B385AC27 for ; Wed, 17 Nov 2021 07:47:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7830B385AC27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637135242; bh=LkML7CAwGmlDIabPoNwFywQEsuvQGuxkhF2MAlH+s50=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ttcNH4vyK0cblceIqqGQnlYMkPyJXliVloh+v7d1NsqVGAU2BxFgD4CUAxRLjpt7g bcCrBlene/MIUYhO8hqicWVFClpkndqR5WC1P05xAh+32YREECzCLoGhSBVmC2bIDX UA5PxRP9p5GTmKMZOa5ZNkoxUB6Qr5/95xB1sx40= 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 642163858C27 for ; Wed, 17 Nov 2021 07:47:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 642163858C27 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AH2nmcr003887 for ; Tue, 16 Nov 2021 23:47:00 -0800 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ccsa0gwtm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 16 Nov 2021 23:47:00 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 16 Nov 2021 23:46:58 -0800 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.18 via Frontend Transport; Tue, 16 Nov 2021 23:46:58 -0800 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 63DBF3F705C; Tue, 16 Nov 2021 23:46:58 -0800 (PST) To: Subject: [PATCH] Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for another bb Date: Tue, 16 Nov 2021 23:46:54 -0800 Message-ID: <1637135214-8113-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: coP5UseG3er5Fx4MrNLnWW90tQKMVtvW X-Proofpoint-GUID: coP5UseG3er5Fx4MrNLnWW90tQKMVtvW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-17_02,2021-11-16_01,2020-04-07_01 X-Spam-Status: No, score=-14.7 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_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Cc: Andrew Pinski Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Andrew Pinski The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks but missed one location where phiopt could move an assignment from the middle block to the non-middle one. This patch fixes that. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR 103288 gcc/ChangeLog: * tree-ssa-phiopt.c (value_replacement): Return early if middle block has more than one pred. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr103288-1.c: New test. --- gcc/testsuite/gcc.c-torture/compile/pr103288-1.c | 6 ++++++ gcc/tree-ssa-phiopt.c | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr103288-1.c diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c b/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c new file mode 100644 index 00000000000..88d1c675599 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr103288-1.c @@ -0,0 +1,6 @@ + +int ui_5; +long func_14_uli_8; +void func_14() { + ui_5 &= (func_14_uli_8 ? 60 : ui_5) ? 5 : 0; +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 6b22f6bedd4..8984a5e15ab 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1381,6 +1381,9 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, } } + if (!single_pred_p (middle_bb)) + return 0; + /* Now optimize (x != 0) ? x + y : y to just x + y. */ gsi = gsi_last_nondebug_bb (middle_bb); if (gsi_end_p (gsi))