From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13979 invoked by alias); 5 Sep 2014 19:05:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13967 invoked by uid 89); 5 Sep 2014 19:05:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Sep 2014 19:05:20 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s85J55Ao012004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 5 Sep 2014 15:05:05 -0400 Received: from [10.3.228.111] (vpn-228-111.phx2.redhat.com [10.3.228.111]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s85J53tN019064; Fri, 5 Sep 2014 15:05:04 -0400 Message-ID: <1409943701.8613.7.camel@surprise> Subject: Re: [PATCH] Add XINSN macro and use it within NEXT_INSN/PREV_INSN (was Re: [PATCH] Force rtl templates to be inlined) From: David Malcolm To: Jeff Law Cc: Andi Kleen , gcc-patches@gcc.gnu.org, Andi Kleen Date: Fri, 05 Sep 2014 19:05:00 -0000 In-Reply-To: <540A04B7.4020704@redhat.com> References: <1409641427-29875-1-git-send-email-andi@firstfloor.org> <1409669743.19403.13.camel@surprise> <20140902175037.GA4120@two.firstfloor.org> <1409861057.19403.19.camel@surprise> <540A04B7.4020704@redhat.com> Content-Type: multipart/mixed; boundary="=-LRiHXPyqYYbbK3VmAIkJ" Mime-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00527.txt.bz2 --=-LRiHXPyqYYbbK3VmAIkJ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Content-length: 2220 On Fri, 2014-09-05 at 12:45 -0600, Jeff Law wrote: > On 09/04/14 14:04, David Malcolm wrote: > > On Tue, 2014-09-02 at 19:50 +0200, Andi Kleen wrote: > >>> I suspect the bulk of them currently are coming from the safe_as_a > >>> calls within NEXT_INSN and PREV_INSN; do you happen to have > >>> information handy on that? > >> > >> Yes that's right: > >> > >> - 1.03% lto1 [.] bool is_a_helper::test(rtx_def*) ▒ > >> - bool is_a_helper::test(rtx_def*) ▒ > >> - 92.20% bool is_a(rtx_def*) ▒ > >> - 98.53% rtx_insn* safe_as_a(rtx_def*) ▒ > >> - 73.28% NEXT_INSN(rtx_insn const*) ▒ > > > > The is_a_helper for rtx_insn * is non-trivial, so it may be worth > > avoiding it, even when inlined. > > > > The attached patch rewrites the inline NEXT_INSN/PREV_INSN to avoid > > doing the safe_as_a, instead tightening up the interface so that one can > > only set them to an insn, and introducing a new XINSN access macro and > > corresponding rt_insn member of the union. > > > > Bootstrapped on x86_64-unknown-linux-gnu (Fedora 20), and has been > > rebuilt as part of a config-list.mk build for all working configurations > > (albeit with other patches for the latter case). > > > > OK for trunk? > So is this just to deal with the overhead in the safe_as_a helper until > we can strengthen more code? And is that overhead significant in an > optimized build? > > Would an alternate approach be to make the checking in safe_as_a > conditionalized on ENABLE_CHECKING? I wrote the attached patch to do that, but I don't yet have numbers to back it up. Bootstrapped with current settings, and smoketested with --enable-checking=release (both on Fedora 20 x86_64). --=-LRiHXPyqYYbbK3VmAIkJ Content-Disposition: attachment; filename*0=0001-Ensure-that-safe_as_a-can-have-no-performance-overhe.pat; filename*1=ch Content-Type: text/x-patch; name="0001-Ensure-that-safe_as_a-can-have-no-performance-overhe.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 961 >From 24b98616c4425a8ef380d2d5fef00f82af9df985 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 29 Aug 2014 17:04:49 -0400 Subject: [PATCH] Ensure that safe_as_a can have no performance overhead in a release build gcc/ * is-a.h (safe_as_a): Eliminate the conditional from the !defined(ENABLE_CHECKING) case, to ensure there can be no performance degradation of the release build. --- gcc/is-a.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/is-a.h b/gcc/is-a.h index 176066b..f0c05b0 100644 --- a/gcc/is-a.h +++ b/gcc/is-a.h @@ -200,6 +200,7 @@ template inline T safe_as_a (U *p) { +#ifdef ENABLE_CHECKING if (p) { gcc_checking_assert (is_a (p)); @@ -207,6 +208,9 @@ safe_as_a (U *p) } else return NULL; +#else + return is_a_helper ::cast (p); +#endif } /* A generic checked conversion from a base type U to a derived type T. See -- 1.8.5.3 --=-LRiHXPyqYYbbK3VmAIkJ--