From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681888694; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=ivkoThgTaQgfa3SmAoyFq+WePklCDmg2sXF5DSp/peU=; b=zWTVfoKsnYEai+xe5y56Vxkz/BJr4LizCY0zQi9Kha5QTxg3iQZa/bIF5B3M7yac7qije5 Z5ZPORgHOvmIAQFR2XvLJ2HRw/SezpjCocqnyI53xwqX9bse/rM/YE5/8yQJgxlQeZ70ax x/4TcOmKGunguFjxLMpLS4EAo49OpDg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681888694; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=ivkoThgTaQgfa3SmAoyFq+WePklCDmg2sXF5DSp/peU=; b=pwdPnM+4AZ/L/a5sDPOXm7MYoKHyD70KR4P4G3L74fdR7UcuvWEs9hYO9TXrhoB0YT7PlM A9FZjOLvhojT7UDg== 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) From: Richard Biener 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 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,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 List-Id: Message-ID: <20230419071814.WG0B7TfUAkiePWZ-WtURdeA__vKwvI8hMsFVZoxQ4Qg@z> 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; -- 2.35.3