From patchwork Wed Apr 19 07:18:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 85228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp177198vqo; Wed, 19 Apr 2023 00:19:12 -0700 (PDT) X-Google-Smtp-Source: AKy350Yx5yZbl3ztq/2ZBqqyTpPORGqJiXWBPtLOL+DKCwyZUBHTnZFAxDkMSCe3NRQ9mIjbwDEC X-Received: by 2002:a05:6402:1a52:b0:506:83fc:2dab with SMTP id bf18-20020a0564021a5200b0050683fc2dabmr4386836edb.22.1681888751889; Wed, 19 Apr 2023 00:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681888751; cv=none; d=google.com; s=arc-20160816; b=lcvZsz4OqC/9RNrwIcvY/PSMcAa9FarOyiErrB1Ckakvh5PP79bdD30xZmJqigjN7H J5JBPhUf7spXzHRkuQfToNbZ4qzWbofsq8E5nHD5OEbpz2j1hhkTHCWZLvhDim/xKkVG 0HaZQTSC27SuO73XFdErDLceV8lEG8m8jUTCQdn5uq17XGEXUv58NFMrFun4Oga5e+zX khkbiXElETkprpIY8Utt4fC60ZmfFxyRGlNMwraKXGujorOO7YmA9juFOAuInTkMJE+T /O+fvA5oW9O4WCKheh4twU2nNR1k5DXEO4fFGSbG71hGt3sBT5VhdcTKfnHKODkRrE2P xRZQ== 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=ivkoThgTaQgfa3SmAoyFq+WePklCDmg2sXF5DSp/peU=; b=g8SzQrrSCBxoUyrlC23tfqfF6ZuVq+BeC6s3kYKKdY5UO7gMIo1taTpxXjej2jC5Cm H9SXcOmkI15Zx6eZX6Czj7Ty2o7q2sW74z/h+nvJ5GHTCBp/UgCfBiX0gReI8beZJQDs QBJIf3E3Y5keuAtOnUz3zorgkQ4jtkppH8EqGkXr2GGjhHrzJMLhIJf3yxQf03eQTidh fzL8KyKXN5U7XnTLZFpwPjCsG7W4H7G8A9sAytR8bLmX3b70CvitVz7PJ5suykvYiaqz Q1y9RkiJNfuYYWhorYf9qk3VfemV25kksBkVelKU+dCQTndrXMKeXiv3riY4jFiO5tqg yjxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dmqHf0dM; 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 dy8-20020a05640231e800b005021f2d55a0si14370346edb.679.2023.04.19.00.19.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 00:19:11 -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=dmqHf0dM; 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 61BB83856949 for ; Wed, 19 Apr 2023 07:19:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61BB83856949 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681888740; bh=ivkoThgTaQgfa3SmAoyFq+WePklCDmg2sXF5DSp/peU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dmqHf0dMcgevfQVPW8Pac0lsIuoYniPyY8RY+SBPNHcE9ROGjtzdocjpS/ua9rG31 UcNOpEiOKpR7/eATFLtltn3MQzRe54Tb2j1WxyVTaLo0RdoclCZMyqO6k0hRKwipL+ Fv8FjvMbgIe70icJ6iCmpo6z4YC07LaEa3fOs0d0= 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 [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id DAE513857835 for ; Wed, 19 Apr 2023 07:18:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAE513857835 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9F76221989 for ; Wed, 19 Apr 2023 07:18:14 +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 960612C141 for ; Wed, 19 Apr 2023 07:18:14 +0000 (UTC) Date: Wed, 19 Apr 2023 07:18:14 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] rtl-optimization/109237 - speedup bb_is_just_return 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, 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 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: <20230419071900.61BB83856949@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763588180046109522?= X-GMAIL-MSGID: =?utf-8?q?1763588180046109522?= For the testcase bb_is_just_return is on top of the profile, changing it to walk BB insns backwards puts it off the profile. That's because in the forward walk you have to process possibly many debug insns but in a backward walk you very likely run into control insns first. This is a fixed version of the patch originally applied and reverted. Re-bootstrap & regtest running on x86_64-unknown-linux-gnu, will push after that re-succeeds. Richard. PR rtl-optimization/109237 * cfgcleanup.cc (bb_is_just_return): Walk insns backwards. --- gcc/cfgcleanup.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/cfgcleanup.cc b/gcc/cfgcleanup.cc index 194e0e5de12..78f59e99653 100644 --- a/gcc/cfgcleanup.cc +++ b/gcc/cfgcleanup.cc @@ -2608,14 +2608,14 @@ bb_is_just_return (basic_block bb, rtx_insn **ret, rtx_insn **use) if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun)) return false; - FOR_BB_INSNS (bb, insn) + FOR_BB_INSNS_REVERSE (bb, insn) if (NONDEBUG_INSN_P (insn)) { rtx pat = PATTERN (insn); if (!*ret && ANY_RETURN_P (pat)) *ret = insn; - else if (!*ret && !*use && GET_CODE (pat) == USE + else if (*ret && !*use && GET_CODE (pat) == USE && REG_P (XEXP (pat, 0)) && REG_FUNCTION_VALUE_P (XEXP (pat, 0))) *use = insn;