From patchwork Mon Aug 1 13:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp2354922pxt; Mon, 1 Aug 2022 07:00:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vBM8snnWKiIqGFSXHDaaGf3OvkWjl0sMQh6uqviEwczeM3/wKb3PwPEmQlgiaAM6pqm/zR X-Received: by 2002:a17:907:3daa:b0:72b:7656:d4d2 with SMTP id he42-20020a1709073daa00b0072b7656d4d2mr12721428ejc.166.1659362427196; Mon, 01 Aug 2022 07:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659362427; cv=none; d=google.com; s=arc-20160816; b=CKcGfi25Nt8AbvFzJRMJ1e0V6HgG3J3ca4HiecYBn9Hvu0IfPyyE+HHDcIi4t1l/l6 KdWQTArIl8xKKWhMl/ll1LhH/2OPT9buF73uqLwtm3gcOTyIkwFcsrjZehZ/S1v2z5q3 caQpl07hyYPjj3jpCbN1ZWepxnrvBqQ+CwbsdfkCH8M3TFsb9IKgo8CCJC7j7c4UAFQY +wYPFk/gpnWEwaO68oaUT1CBYRgw1fd5q2dzq7Ii+BuV/8Znu9YQwGHH+6nqyNxjqIDq s4U7F3UnoqgaJJBdifg3TdYr408zPdn+MzCiV2KGMW5pWGttVJK/XT4z1Hkx+bTFILxk j+oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=kop9Psp4emEbXD9q3gxnvd5nR1gburmE/WytGs9ltNc=; b=YyUCspIbeyJPXzDEVcm7khyClzRySr+dDgIafZsy3x4D3HtSKrF/va+KjydZYcrU10 U0eWyMKg7VxHuFic5Mx9n5j7YIIQVWZwV1v9towkiYLR0ra73hBOTrD8lmrWnDeF03kC q83qv3k8qK74SZtGvduaK8Kitb7iVmd/sk3fk9zvZmlMBPtORbrTFqqTYixA05o0E44H YwjFPLamk/y69ysh7FdqlYN5feLoHHsL31VmcBWkN5gJ3nNT7VZYMleQPG+3VqgsAhjx ofJBWcykZXoEjFvU2L8n8msNke6Aysi0RkUguLsl2upzUnNqgtQnlSuT2Iy8Ugvp3Kw+ SiSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RFsqfVw6; 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 n8-20020a05640205c800b0043a6efbaaa4si10797186edx.301.2022.08.01.07.00.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 07:00:27 -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=RFsqfVw6; 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 10138385840C for ; Mon, 1 Aug 2022 14:00:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10138385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659362426; bh=kop9Psp4emEbXD9q3gxnvd5nR1gburmE/WytGs9ltNc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RFsqfVw6KIF1AZZHVasZY/a8LNG5awcnQBCbQeGKUzJOPDKLT7JkQU0WaLr1vUEib CHGsnuJp0bFnreds46NFSD+OEMwx/lLQRrcP6J+Tda6CZTXZDMwrvI2A2cOt1Tcbo5 42SBvKu4+rCYHugB8Rv/M7XI9wNH+a7TNSG7CXDA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 077683858D39 for ; Mon, 1 Aug 2022 13:59:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 077683858D39 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D635E2083B for ; Mon, 1 Aug 2022 13:59:39 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D05A52C141 for ; Mon, 1 Aug 2022 13:59:39 +0000 (UTC) Date: Mon, 1 Aug 2022 13:59:39 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106495 - avoid threading to possibly never executed edge User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20220801140026.10138385840C@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739967616586763829?= X-GMAIL-MSGID: =?utf-8?q?1739967616586763829?= The following builds upon the logic of the PR105679 fix by avoiding to thread to a known edge that is predicted as probably never executed. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. PR tree-optimization/106495 * tree-ssa-threadbackward.cc (back_threader_profitability::profitable_path_p): If known_edge is probably never executed avoid threading. --- gcc/tree-ssa-threadbackward.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index 90f5331c265..0519f2a8c4b 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -777,6 +777,13 @@ back_threader_profitability::profitable_path_p (const vec &m_path, "exceeds PARAM_MAX_FSM_THREAD_PATH_INSNS.\n"); return false; } + if (taken_edge && probably_never_executed_edge_p (cfun, taken_edge)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " FAIL: Jump-thread path not considered: " + "path leads to probably never executed edge.\n"); + return false; + } edge entry = find_edge (m_path[m_path.length () - 1], m_path[m_path.length () - 2]); if (probably_never_executed_edge_p (cfun, entry))