From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: Richard Biener 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 Content-Type: text/plain; charset=US-ASCII 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-List-Received-Date: Mon, 01 Aug 2022 13:59:43 -0000 Message-ID: <20220801135939.5hywrvI9Ct3UYk9GIbwws0P_W84qITpI8Bvnz0qe1Ho@z> 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)) -- 2.35.3