From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21307 invoked by alias); 30 Mar 2012 08:16:12 -0000 Received: (qmail 21284 invoked by uid 22791); 30 Mar 2012 08:16:04 -0000 X-SWARE-Spam-Status: No, hits=-4.8 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-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Mar 2012 08:15:50 +0000 Received: by iaag37 with SMTP id g37so705119iaa.20 for ; Fri, 30 Mar 2012 01:15:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.161.225 with SMTP id xv1mr709637igb.35.1333095350184; Fri, 30 Mar 2012 01:15:50 -0700 (PDT) Received: by 10.42.228.200 with HTTP; Fri, 30 Mar 2012 01:15:50 -0700 (PDT) In-Reply-To: References: Date: Fri, 30 Mar 2012 08:16:00 -0000 Message-ID: Subject: Re: Missed optimization in PRE? From: Richard Guenther To: "Bin.Cheng" 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/msg00514.txt.bz2 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 wrot= e: >>> On Thu, Mar 29, 2012 at 6:07 PM, Richard Guenther >>> wrote: >>>> On Thu, Mar 29, 2012 at 12:02 PM, Bin.Cheng wr= ote: >>>>> 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 pass= can sink >> loads, so this must be a missed optimization. >> > Curiously, it is said explicitly that "We don't want to sink loads from m= emory." > 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 stores, separating them (like a scheduler would do). We'd want to restrict sinking of loads to sink into not post-dominated regions (thus where they end up being executed less times). Richard. > > -- > Best Regards.