From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96633 invoked by alias); 29 Apr 2015 14:06:16 -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 96619 invoked by uid 89); 29 Apr 2015 14:06:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 29 Apr 2015 14:06:14 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 37F1D54054F; Wed, 29 Apr 2015 16:06:10 +0200 (CEST) Date: Wed, 29 Apr 2015 14:31:00 -0000 From: Jan Hubicka To: Richard Biener Cc: Jan Hubicka , Eric Botcazou , GCC Patches Subject: Re: [patch] Perform anonymous constant propagation during inlining Message-ID: <20150429140609.GA30007@kam.mff.cuni.cz> References: <6476732.lMFodJZTVz@polaris> <20150429132320.GD9659@atrey.karlin.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-04/txt/msg01884.txt.bz2 > On Wed, Apr 29, 2015 at 3:23 PM, Jan Hubicka wrote: > >> Historically the pragma Inline_Always of GNAT had been implemented in the FE > >> because the RTL inliner and then the Tree inliner weren't invoked at -O0 or > >> powerful enough to inline some constructs. But this approach had drawbacks, > >> especially wrt debug info. These restrictions were gradually lifted and now > >> the pragma is entirely piggybacked on the Tree inliner. > >> > >> This went mostly OK, except for a few cases where intrisinc operations that > >> used to be reasonably handled at -O0 now generate awful code, the typical > >> example being a modulus or division instrinsic by a power-of-2 generating a > >> fully-fledged modulus or division instruction instead of a simple shift. > >> > >> Therefore the attached patch implements anonymous constant propagation in the > >> inliner to fix the code quality regression. > >> > >> Tested on x86_64-suse-linux, OK for the mainline? > >> > >> if (TREE_CODE (*tp) == SSA_NAME) > >> { > >> - *tp = remap_ssa_name (*tp, id); > >> + tree t = remap_ssa_name (*tp, id); > >> + /* Perform anonymous constant propagation, this makes it possible to > >> + generate reasonable code even at -O0 for operators implemented as > >> + inline functions. */ > >> + if (TREE_CODE (t) == SSA_NAME > >> + && SSA_NAME_DEF_STMT (t) > >> + && (!SSA_NAME_VAR (t) || DECL_IGNORED_P (SSA_NAME_VAR (t))) > >> + && gimple_assign_copy_p (SSA_NAME_DEF_STMT (t)) > >> + && is_gimple_min_invariant > >> + (gimple_assign_rhs1 (SSA_NAME_DEF_STMT (t)))) > >> + *tp = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (t)); > >> + else > >> + *tp = t; > > > > This looks like a good idea to me (though i can't approve it). We may want to > > lift the (!SSA_NAME_VAR (t) || DECL_IGNORED_P (SSA_NAME_VAR (t))) when optimize > > is set - the amount of garbage inliner produce is large and killing it early is > > better than killing it later. This has chance to help early opts where > > ordering between ccp and einline is quite hard. > > Early opts run CCP as pretty much the first pass, so I don't see what > you are refering to here. Hmm, you are right. I remember playing with similar patch but that was before we turned off iteration in early inliner and it was motivated to do more of indirect call promotion. Since ipa-prop is no longer complete joke on propagating devirutalization info perhaps this is no longer too important. honza