From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55284 invoked by alias); 29 Apr 2015 11:55:09 -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 55270 invoked by uid 89); 29 Apr 2015 11:55:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f173.google.com Received: from mail-ob0-f173.google.com (HELO mail-ob0-f173.google.com) (209.85.214.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 29 Apr 2015 11:55:07 +0000 Received: by oblw8 with SMTP id w8so17893747obl.0 for ; Wed, 29 Apr 2015 04:55:05 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.228.71 with SMTP id b68mr17171017oih.58.1430308505881; Wed, 29 Apr 2015 04:55:05 -0700 (PDT) Received: by 10.76.115.167 with HTTP; Wed, 29 Apr 2015 04:55:05 -0700 (PDT) In-Reply-To: <6476732.lMFodJZTVz@polaris> References: <6476732.lMFodJZTVz@polaris> Date: Wed, 29 Apr 2015 12:06:00 -0000 Message-ID: Subject: Re: [patch] Perform anonymous constant propagation during inlining From: Richard Biener To: Eric Botcazou Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg01864.txt.bz2 On Wed, Apr 29, 2015 at 11:50 AM, Eric Botcazou 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? Hmm, special-casing this in the inliner looks odd to me. ISTR the inliner already propagates constant parameters to immediate uses, so I guess you run into the casting case you handle specially. But then if any constant propagation is ok at -O0 why not perform full-fledged constant propagation (with !DECL_IGNORED_P vars as a propagation barrier) as a regular SSA pass? That is, if you'd had a Inline_Always function like int foo (int i) { return (i + 1) / i; } you'd not get the desired result as the i + 1 stmt wouldn't be folded and thus the (i + 1) / i stmt wouldn't either. That said - why does RTL optimization not save you here anyway? After all, it is responsible for turning divisions into shifts. Soo - if you use the existing CCP pass and make surely_varying_stmt_p return true for defs of !DECL_IGNORED_P stmts at -O0 (strictly needed to make setting vars in gdb possible) and somehow arrange for ccp to run at -O0... It might help other obscure cases with inline-asms to behave consistently with -O0 vs. -On as well. Richard. > 2015-04-29 Eric Botcazou > > * tree-inline.c (remap_gimple_op_r): Do anonymous constant propagation. > (copy_bb): Fold conversions of constants immediately. > > > 2015-04-29 Eric Botcazou > > * gnat.dg/inline12.adb: New test. > > > -- > Eric Botcazou