From patchwork Tue Aug 2 13:00:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp2962482pxt; Tue, 2 Aug 2022 06:01:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dx1hI6QM4pPP0Cb56G2/Ekw3e3PEdWa5Qwq4Mq399HM0563ch+S+yEjxDZIo/nmIh2P3z X-Received: by 2002:a05:6402:190d:b0:43d:f64f:9a0e with SMTP id e13-20020a056402190d00b0043df64f9a0emr2837442edz.346.1659445300996; Tue, 02 Aug 2022 06:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659445300; cv=none; d=google.com; s=arc-20160816; b=nhR7R/ngOf640InoqBP45JQH0qlk1Lm26BUhepYe4GGuFYWjXmmzr9j6nF2Ns76q5J 5IJsAzED1/x1oDc+xXW9LKFUIXwMuQ8vGWJZE6WkpYRy61G4zaZxq8qhVeRy1O7JsWKd q3xM11eXTA3PQ5C1iHWriqQ9yZg4qVZfkGshNtTVbIReJZnMX0h3LBLN8ZhCPz+YRbhu SMQp+9RGJ5pP0QiSTy0Pk4ugMyjAFS6MVvfCKzGsa3q4n3vbp00msLe1OhcOV0H+XYdx T2h+MJmp57YsuY5GhXWgUsA52T3aqhx1J70WrblvNUChhzRZ4YCXxGHULkVBbt2aw3Xn +cUg== 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=kCrMS9KUPDLfxmbMb8xELgjzLuWZVfuG5UsaAX0SVxo=; b=nLccFsyAY93o7hXXBE8ZjZl8poe56yrMk7LD6N1aB3UC84nMl0AXZAgMO1H4vDDveZ ahVfzkkm/p6RDUOhkj3sBupeEkRhjTPIPhRvk1a9sTJ9POn8fToRagtNv1fQZ2BdgXyc UToKmyhzbCFVMhe2o80Xkenv0uGqTkVc2BWnC+axecvVxFWdIz3QbVUyM6mUYnlBZQXW PzqY9BAg/9DqmloekEPO/UQPiT0XoFcuks07XLYudA7UH8fvMOfn7j3hkpP6FNDZ2DwO enhJUR3x1Vks0Gfycx1yLmQi/cMmJ9JTSrNtELf5laigDpMa/EiHWxZdGTCQyY4CG4hz InHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=F+GdWjWb; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a1-20020a05640213c100b0043cec8a1304si11320753edx.528.2022.08.02.06.01.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 06:01:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=F+GdWjWb; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 A5BB33856095 for ; Tue, 2 Aug 2022 13:01:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5BB33856095 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659445299; bh=kCrMS9KUPDLfxmbMb8xELgjzLuWZVfuG5UsaAX0SVxo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=F+GdWjWbnqXuGGMRh6MwA/yW6w1Y8GPxGrRytSYZ09v3UL3J3jQ5OJYwsEQj5zjs7 eczEg0jFOClfqgQj5vwteP9KSkcE11kCIpB2BxD+QFG59p07sI4JGhb4jKNDTgsfjT p2EqU+MENYqEM45WVtFsiwuNnvZabBaXveFlEWMs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 3E5ED385AE4F for ; Tue, 2 Aug 2022 13:00:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E5ED385AE4F Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3692A3384C for ; Tue, 2 Aug 2022 13:00:55 +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 31B6B2C141 for ; Tue, 2 Aug 2022 13:00:55 +0000 (UTC) Date: Tue, 2 Aug 2022 13:00:55 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Properly honor param_max_fsm_thread_path_insns in backwards threader 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: <20220802130139.A5BB33856095@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740044511152956809?= X-GMAIL-MSGID: =?utf-8?q?1740054516137509000?= I am trying to make sense of back_threader_profitability::profitable_path_p and the first thing I notice is that we do /* Threading is profitable if the path duplicated is hot but also in a case we separate cold path from hot path and permit optimization of the hot path later. Be on the agressive side here. In some testcases, as in PR 78407 this leads to noticeable improvements. */ if (m_speed_p && ((taken_edge && optimize_edge_for_speed_p (taken_edge)) || contains_hot_bb)) { if (n_insns >= param_max_fsm_thread_path_insns) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " FAIL: Jump-thread path not considered: " "the number of instructions on the path " "exceeds PARAM_MAX_FSM_THREAD_PATH_INSNS.\n"); return false; } ... } else if (!m_speed_p && n_insns > 1) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " FAIL: Jump-thread path not considered: " "duplication of %i insns is needed and optimizing for size.\n", n_insns); return false; } ... return true; thus we apply the n_insns >= param_max_fsm_thread_path_insns only to "hot paths". The comment above this isn't entirely clear whether this is by design ("Be on the aggressive side here ...") but I think this is a mistake. In fact the "hot path" check seems entirely useless since if the path is not hot we simply continue threading it. This was caused by r12-324-g69e5544210e3c0 and the following simply reverts the offending change. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-ssa-threadbackwards.cc (back_threader_profitability::profitable_path_p): Apply size constraints to all paths again. --- gcc/tree-ssa-threadbackward.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index 0519f2a8c4b..ba114e98a41 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -794,7 +794,7 @@ back_threader_profitability::profitable_path_p (const vec &m_path, return false; } } - else if (!m_speed_p && n_insns > 1) + else if (n_insns > 1) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " FAIL: Jump-thread path not considered: "