From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120785 invoked by alias); 26 May 2015 17:30:27 -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 120771 invoked by uid 89); 26 May 2015 17:30:27 -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; Tue, 26 May 2015 17:30:26 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 585F6543A96; Tue, 26 May 2015 19:30:22 +0200 (CEST) Date: Tue, 26 May 2015 18:53:00 -0000 From: Jan Hubicka To: Richard Biener Cc: Jan Hubicka , gcc-patches@gcc.gnu.org, mliska@suse.cz Subject: Re: Add few cases to operand_equal_p Message-ID: <20150526173022.GC43680@kam.mff.cuni.cz> References: <20150522123341.GD91616@kam.mff.cuni.cz> <20150522135025.GE75713@kam.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-05/txt/msg02363.txt.bz2 > > Will do if we agree on having this. > > > > I know you would like ipa-icf to keep original bodies and use them for > > inlining declaring alias sets to be function local. This is wrong plan. > > Consder: > > > > void t(int *ptr) > > { > > *ptr=1; > > } > > > > int a(int *ptr1, int *ptr2) > > { > > int a = *ptr1; > > t(ptr2) > > return a+*ptr1; > > } > > > > long b(long *ptr1, int *ptr2) > > { > > int a = *ptr1; > > t(ptr2) > > return a+*ptr1; > > } > > > > here aliasing leads to the two options to be optimizer differently: > > a: > > .LFB1: > > .cfi_startproc > > movl 4(%esp), %edx > > movl 8(%esp), %ecx > > movl (%edx), %eax > > movl $1, (%ecx) > > addl (%edx), %eax > > ret > > .cfi_endproc > > b: > > .LFB2: > > .cfi_startproc > > movl 4(%esp), %eax > > movl 8(%esp), %edx > > movl (%eax), %eax > > movl $1, (%edx) > > addl %eax, %eax > > ret > > .cfi_endproc > > > > however with -fno-early-inlining the functions look identical (modulo alias > > sets) at ipa-icf time. If we merged a/b, we could get wrong code for a > > even though no inlining of a or b happens. > > First of all the return types don't agree so the testcase is bogus. With -m32 they are types_compatible_p because they are of same size. > > > So either we match the alias sets or we need to verify that the alias sets > > permit precisely the same set of optimizations with taking possible inlining > > into account. > > Hmm, but then what makes ICF of a and b _with_ early inlining fail with > -fno-tree-fre1? The casts from *ptr1 to int in the 'long' case. Dereferencing *ptr1 that has different alias set in each function. > > So I think I need to see a real testcase and then I'll show you > even with no inlining after ICF you get wrong-code thus it is a bug > in ICF ;) I added the inline only to make it clear that the loads won't be optimized at early optimization time. long a(int *ptr1, int *ptr2) { int a = *ptr1; *ptr2=1; return a+*ptr1; } long b(long *ptr1, int *ptr2) { int a = *ptr1; *ptr2=1; return a+*ptr1; } with -fno-tree-fre may be more real a (int * ptr1, int * ptr2) { int a; int D.1380; long int D.1379; int _4; long int _5; : a_2 = *ptr1_1(D); *ptr2_3(D) = 1; _4 = *ptr1_1(D); _5 = _4 + a_2; : return _5; } ;; Function b (b, funcdef_no=1, decl_uid=1375, cgraph_uid=1) b (long int * ptr1, int * ptr2) { int a; long int D.1383; long int D.1382; long int _4; long int _5; : a_2 = *ptr1_1(D); *ptr2_3(D) = 1; _4 = *ptr1_1(D); _5 = _4 + a_2; : return _5; } > > > I also do not believe that TBAA should be function local. I believe it is > > useful to propagate stuff interprocedurally, like ipa-prop could be able to > > propagate this: > > > > long *ptr1; > > int *ptr2; > > t(int *ptr) > > { > > return *ptr; > > } > > wrap(int *ptr) > > { > > *ptr1=1; > > } > > call() > > { > > return wrap (*ptr2); > > } > > > > and we could have ipa-reference style pass that collect alias sets > > read/written by a function and uses it during local optimization to > > figure out if there is a true dependence between function call and > > memory store. > > Sure, but after ICF there is no IPA propagation... Doesn't matter if you propagate before or after ICF. If you do before, ICF would need to match/merge the alias set in optimization summary to be sure that the functions are same. Honza > > Richard. > > -- > Richard Biener > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)