From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 084853858D39 for ; Tue, 28 Mar 2023 07:49:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 084853858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679989758; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Kbis6xZ2KfQtkr1jN+/aiufPFkVBTtlHxk0PeAutMwM=; b=C6Oab1zw/G+EomaicRnJ6yU3UcyvHUkdbOK6ET1STjH7tO1D3MCK5DNwIlA8/ZE4vyenqY 2C3PgC1WijEY4mRcFlcD8OTAPq+/s3yln0Z7LeWTdu4NbBpqcqOyL6dU6daVnftHyosE3L GzACXK7AaiCBOWksELqD4rzl/WAPCv0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-99-N4_Ti4lXOuy30He0QIgI-A-1; Tue, 28 Mar 2023 03:49:16 -0400 X-MC-Unique: N4_Ti4lXOuy30He0QIgI-A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FFCC101A550; Tue, 28 Mar 2023 07:49:16 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53C69492C3E; Tue, 28 Mar 2023 07:49:16 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32S7nD9p1441805 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 09:49:14 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32S7nDai1441804; Tue, 28 Mar 2023 09:49:13 +0200 Date: Tue, 28 Mar 2023 09:49:12 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] rtl-optimization/109237 - speedup bb_is_just_return Message-ID: Reply-To: Jakub Jelinek References: <20230322100356.5B99E3857C48@sourceware.org> MIME-Version: 1.0 In-Reply-To: <20230322100356.5B99E3857C48@sourceware.org> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Wed, Mar 22, 2023 at 10:03:42AM +0000, Richard Biener via Gcc-patches wrote: > 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. > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. > > OK? > > For the record, the profile was (after the delete_trivially_dead_insns > fix) > > Samples: 289K of event 'cycles:u', Event count (approx.): 384226334976 > Overhead Samples Command Shared Object Symbol > 3.52% 9747 cc1 cc1 [.] bb_is_just_return > # > > and after the fix bb_is_just_return has no recorded samples anymore. > > Thanks, > Richard. > > PR rtl-optimization/109237 > * cfgcleanup.cc (bb_is_just_return): Walk insns backwards. This seems to regress +FAIL: gcc.dg/guality/pr54200.c -Os -DPREVENT_OPTIMIZATION line 20 z == 3 on x86_64. This was meant just as a performance improvement, right? Just with -Os -g0 the assembly difference is: --- pr54200.s1 2023-03-28 09:45:57.120647323 +0200 +++ pr54200.s2 2023-03-28 09:46:00.423599004 +0200 @@ -19,10 +19,11 @@ foo: cmpl $1, %esi jne .L3 movl $2, o(%rip) - ret + jmp .L4 .L3: addl %esi, %eax addl %edx, %eax +.L4: ret .cfi_endproc .LFE1: so 1 byte longer (ret is 1 byte, jmp 2 bytes), but might be also slower. The difference starts during the pro_and_epilogue pass. > --- a/gcc/cfgcleanup.cc > +++ b/gcc/cfgcleanup.cc > @@ -2608,7 +2608,7 @@ 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); > -- > 2.35.3 Jakub