public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <rguenther@suse.de>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org, mliska@suse.cz
Subject: Re: Add few cases to operand_equal_p
Date: Tue, 26 May 2015 18:53:00 -0000	[thread overview]
Message-ID: <20150526173022.GC43680@kam.mff.cuni.cz> (raw)
In-Reply-To: <alpine.LSU.2.11.1505261306000.30088@zhemvz.fhfr.qr>

> > 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;

  <bb 2>:
  a_2 = *ptr1_1(D);
  *ptr2_3(D) = 1;
  _4 = *ptr1_1(D);
  _5 = _4 + a_2;

<L0>:
  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;

  <bb 2>:
  a_2 = *ptr1_1(D);
  *ptr2_3(D) = 1;
  _4 = *ptr1_1(D);
  _5 = _4 + a_2;

<L0>:
  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 <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)

  reply	other threads:[~2015-05-26 17:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 12:44 Jan Hubicka
2015-05-22 13:34 ` Richard Biener
2015-05-22 14:01   ` Jan Hubicka
2015-05-22 14:59     ` Jan Hubicka
2015-05-26 12:19     ` Richard Biener
2015-05-26 18:53       ` Jan Hubicka [this message]
2015-05-27  8:39         ` Richard Biener
2015-05-28  0:26           ` Jan Hubicka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150526173022.GC43680@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).