From patchwork Thu Nov 8 14:52:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 197846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A2F962C00C6 for ; Fri, 9 Nov 2012 01:52:52 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352991173; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:Mail-Followup-To:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To: User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=gs631fv XlIHBQW5gZ2qtu2NdYc4=; b=E15siKg5RAMpc3gFgV0LG8AQ55tKx18iaOXSreB LjlyS8108mfu8eoRZWVgx7waY59Rcxkdqn6+zfgnrJ3LyaZk3M5GjxWrTe3BPN+G eqF5BH4NKxsUTMDBWe8bCfccwXj+3AlqZFE+sDUkt8D93soMSI5JSFKZAfVhJu6r V4Wc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=oDV61VaNI81Xy3nwiA3lrZEFaIBY3YQDXuFg08l21PFst8CJjLQsZITmtYUaxn /Oi6b6aJKGWwCcE5zIXij9UL/vP5NVPv1YiqjfCfANfIBBMofwzuwVwifTj1a6Ie lj+5RntTVgim5DJCUW77AUkalRFHm1vXMMSCOPGvRzk/o=; Received: (qmail 5922 invoked by alias); 8 Nov 2012 14:52:43 -0000 Received: (qmail 5914 invoked by uid 22791); 8 Nov 2012 14:52:42 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Nov 2012 14:52:31 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id EB29DA24CA; Thu, 8 Nov 2012 15:52:29 +0100 (CET) Date: Thu, 8 Nov 2012 15:52:29 +0100 From: Martin Jambor To: Jan Hubicka Cc: Jakub Jelinek , GCC Patches Subject: Re: [PATCH] Make IPA-CP work on aggregates Message-ID: <20121108145229.GD24044@virgil.arch.suse.de> Mail-Followup-To: Jan Hubicka , Jakub Jelinek , GCC Patches References: <20121105235806.GG5617@virgil.arch.suse.de> <20121106133530.GW1881@tucnak.redhat.com> <20121107143915.GB24044@virgil.arch.suse.de> <20121107144133.GC1881@tucnak.redhat.com> <20121107145516.GC12897@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20121107145516.GC12897@kam.mff.cuni.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, On Wed, Nov 07, 2012 at 03:55:16PM +0100, Jan Hubicka wrote: > > On Wed, Nov 07, 2012 at 03:39:15PM +0100, Martin Jambor wrote: > > > another bootstrap finishes. I'm not sure if it would be OK to commit > > > it now, given it is stage3, though. OTOH, I think it would be worth > > > it. > > > > I'm ok with getting that in now from RM POV, but not familiar with the > > code enough to review it. So, if somebody acks it (Honza?), it can be > > added. > > > > > 2012-11-07 Martin Jambor > > > > > > * ipa-prop.c (determine_known_aggregate_parts): Skip writes to > > > different declarations when tracking writes to a declaration. > > > > > > Index: src/gcc/ipa-prop.c > > > =================================================================== > > > --- src.orig/gcc/ipa-prop.c > > > +++ src/gcc/ipa-prop.c > > > @@ -1318,7 +1318,12 @@ determine_known_aggregate_parts (gimple > > > break; > > > } > > > else if (lhs_base != arg_base) > > > - break; > > > + { > > > + if (DECL_P (lhs_base)) > > > + continue; > > > + else > > > + break; > > > + } > > OK, so the point of patch is to not stop on writes to decls while looking > for value the field is initialized to? > > It looks OK. Yes, when we are looking for writes to a decl and come accross a write to another decl, we just skip it instead of bailing out completely. The reason my original implementation missed it is that I relied on stmt_may_clobber_ref_p_1 to determine it could not clobber the decl but apprently it does not... perhaps that is a bug? Anyway, I added a testcase to the above and this is what I am about to commit. Thanks a lot, Martin 2012-11-07 Martin Jambor * ipa-prop.c (determine_known_aggregate_parts): Skip writes to different declarations when tracking writes to a declaration. * gfortran.dg/ipcp-array-1.f90: New test. Index: src/gcc/ipa-prop.c =================================================================== --- src.orig/gcc/ipa-prop.c +++ src/gcc/ipa-prop.c @@ -1318,7 +1318,12 @@ determine_known_aggregate_parts (gimple break; } else if (lhs_base != arg_base) - break; + { + if (DECL_P (lhs_base)) + continue; + else + break; + } if (lhs_offset + lhs_size < arg_offset || lhs_offset >= (arg_offset + arg_size)) Index: src/gcc/testsuite/gfortran.dg/ipcp-array-1.f90 =================================================================== --- /dev/null +++ src/gcc/testsuite/gfortran.dg/ipcp-array-1.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-O2 -fdump-ipa-cp-details -fno-inline -fdump-tree-optimized" } + +subroutine bar (a, b, n) + integer :: a(n), b(n) + call foo (a, b) +contains +subroutine foo (a, b) + integer :: a(:), b(:) + a = b +end subroutine +end + +! { dg-final { scan-ipa-dump "Creating a specialized node of foo" "cp" } } +! { dg-final { scan-ipa-dump-times "Aggregate replacements\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=\[^=\]*=" 2 "cp" } } +! { dg-final { cleanup-ipa-dump "cp" } } +! { dg-final { scan-tree-dump-not "stride;" "optimized" } } +! { dg-final { scan-tree-dump-not "lbound;" "optimized" } } +! { dg-final { cleanup-tree-dump "optimized" } }