From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21423 invoked by alias); 30 Mar 2012 09:43:49 -0000 Received: (qmail 21415 invoked by uid 22791); 30 Mar 2012 09:43:48 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Mar 2012 09:43:35 +0000 Received: by yhjj56 with SMTP id j56so170630yhj.20 for ; Fri, 30 Mar 2012 02:43:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.78.72 with SMTP id f48mr1238462yhe.121.1333100615104; Fri, 30 Mar 2012 02:43:35 -0700 (PDT) Received: by 10.147.153.12 with HTTP; Fri, 30 Mar 2012 02:43:35 -0700 (PDT) In-Reply-To: References: Date: Fri, 30 Mar 2012 09:43:00 -0000 Message-ID: Subject: Re: Missed optimization in PRE? From: "Bin.Cheng" To: Richard Guenther Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg00523.txt.bz2 On Fri, Mar 30, 2012 at 4:15 PM, Richard Guenther wrote: > On Thu, Mar 29, 2012 at 5:25 PM, Bin.Cheng wrote: >> On Thu, Mar 29, 2012 at 6:14 PM, Richard Guenther >> wrote: >>> On Thu, Mar 29, 2012 at 12:10 PM, Bin.Cheng wro= te: >>>> On Thu, Mar 29, 2012 at 6:07 PM, Richard Guenther >>>> wrote: >>>>> On Thu, Mar 29, 2012 at 12:02 PM, Bin.Cheng w= rote: >>>>>> Hi, >>>>>> Following is the tree dump of 094t.pre for a test program. >>>>>> Question is loads of D.5375_12/D.5375_14 are redundant on path >>>>> bb7, bb5, bb6>, >>>>>> but why not lowered into basic block 3, where it is used. >>>>>> >>>>>> BTW, seems no tree pass handles this case currently. >>>>> >>>>> tree-ssa-sink.c should do this. >>>>> >>>> It does not work for me, I will double check and update soon. >>> >>> Well, "should" as in, it's the place to do it. =A0And certainly the pas= s can sink >>> loads, so this must be a missed optimization. >>> >> Curiously, it is said explicitly that "We don't want to sink loads from = memory." >> in tree-ssa-sink.c function statement_sink_location, and the condition is >> >> =A0if (stmt_ends_bb_p (stmt) >> =A0 =A0 =A0|| gimple_has_side_effects (stmt) >> =A0 =A0 =A0|| gimple_has_volatile_ops (stmt) >> =A0 =A0 =A0|| (gimple_vuse (stmt) && !gimple_vdef (stmt)) >> <-----------------check load >> =A0 =A0 =A0|| (cfun->has_local_explicit_reg_vars >> =A0 =A0 =A0 =A0 =A0&& TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))) = =3D=3D BLKmode)) >> =A0 =A0return false; >> >> I haven't found any clue about this decision in ChangeLogs. > > Ah, that's probably because usually you want to hoist loads and sink stor= es, > separating them (like a scheduler would do). =A0We'd want to restrict sin= king > of loads to sink into not post-dominated regions (thus where they end up > being executed less times). > Understood, I will work on this. Thanks. --=20 Best Regards.