public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Martin Jambor <mjambor@suse.cz>
Cc: Feng Xue OS <fxue@os.amperecomputing.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Ping: [PATCH V6] Extend IPA-CP to support arithmetically-computed value-passing on by-ref argument (PR ipa/91682)
Date: Tue, 12 Nov 2019 13:29:00 -0000	[thread overview]
Message-ID: <20191112132720.r5ralkbc6se5lc6v@kam.mff.cuni.cz> (raw)
In-Reply-To: <ri6zhh1jkwi.fsf@suse.cz>

> Hi,
> 
> On Tue, Nov 12 2019, Jan Hubicka wrote:
> > Also note that there is a long standing problem with inlining ipacp
> > clones.  This can be shown on the following example:
> >
> > struct a {int a;};
> > static int foo (struct a a)
> > {
> >   return a.a;
> > }
> > __attribute__ ((noinline))
> > static int bar (struct a a)
> > {
> >   return foo(a);
> > }
> > main()
> > {
> >   struct a a={1};
> >   return bar (a);
> > }
> >
> > Now if you compile it with -O2 -fno-early-inlining ipacp correctly
> > determines constants:
> >
> > Estimating effects for bar/1.
> >    Estimating body: bar/1
> >    Known to be false: 
> >    size:6 time:14.000000 nonspec time:14.000000
> >  - context independent values, size: 6, time_benefit: 0.000000
> >      Decided to specialize for all known contexts, code not going to grow.
> > Setting dest_lattice to bottom, because type of param 0 of foo is NULL or unsuitable for bits propagation
> >
> > Estimating effects for foo/0.
> >    Estimating body: foo/0
> >    Known to be false: op0[offset: 0] changed
> >    size:3 time:2.000000 nonspec time:3.000000
> >  - context independent values, size: 3, time_benefit: 1.000000
> >      Decided to specialize for all known contexts, code not going to grow.
> >
> >
> > Yet the intended tranformation to "return 1" does not happen:
> >
> > __attribute__((noinline))
> > bar.constprop (struct a a)
> > {
> >   int a$a;
> >
> >   <bb 2> [local count: 1073741824]:
> >   a$a_5 = a.a;
> >   return a$a_5;
> >
> > }
> >
> >
> >
> > ;; Function main (main, funcdef_no=2, decl_uid=1937, cgraph_uid=3, symbol_order=2) (executed once)
> >
> > main ()
> > {
> >   struct a a;
> >   int _3;
> >
> >   <bb 2> [local count: 1073741824]:
> >   a.a = 1;
> >   _3 = bar.constprop (a); [tail call]
> >   a ={v} {CLOBBER};
> >   return _3;
> >
> > }
> >
> > The problem here is that foo get inlined into bar and we never apply
> > ipcp transform on foo, so a.a never gets constant propagated.  
> 
> Ugh, we never... what?  That is quite bad, how come we don't have PR
> about this?

I remember speaking about it with you few times years ago :)
> 
> >
> > For value ranges this works since late passes are able to propagate
> > constants from value ranges we attach to the default def SSA names.  I
> 
> Well, there are no SSA names for parts of aggregates.

I think all we need is to make FRE's alias oracle walker which is
responsible for propagation of constants to see if it hits entry of
function, check that base is a parameter and look into ipcp transform
summary if known value is there.
> 
> > think correct answer here is to do no subtitution in in ipa-prop.c
> > transform function.  Rather note the known values for late passes and
> > let FRE do its job.
> 
> And where would you like to save it?   Do a load at the beginning of the
> function?  My thinking was that it is better to modify the IL rather
> than storing stuff to ad-hoc on-the-side data structures.

It is already saved in the ipcp transform summary. It is about keeping
it around while copmiling function and using it same way as we use, say
results of ipa-reference analysis.

Honza
> 
> Martin

  reply	other threads:[~2019-11-12 13:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 12:35 [PATCH] Extend IPA-CP to support arithmetically-computed value-passing on by-ref argument (PR ipa/91682)) Feng Xue OS
2019-09-06 16:39 ` [PATCH V2] " Feng Xue OS
2019-09-09  8:40   ` [PATCH V3] " Feng Xue OS
2019-09-19 14:30     ` [PATCH V4] Extend IPA-CP to support arithmetically-computed value-passing on by-ref argument (PR ipa/91682) Feng Xue OS
2019-09-30  8:53       ` Ping: " Feng Xue OS
2019-10-23  8:25         ` luoxhu
2019-10-23  8:29           ` Feng Xue OS
2019-11-04  9:39             ` Ping: [PATCH V5] " Feng Xue OS
2019-11-05  1:40               ` Martin Jambor
2019-11-05  9:35                 ` Ping: [PATCH V6] " Feng Xue OS
2019-11-12 12:34                   ` Jan Hubicka
2019-11-12 12:35                     ` Jan Hubicka
2019-11-12 13:17                       ` Martin Jambor
2019-11-12 13:29                         ` Jan Hubicka [this message]
2019-11-13 13:58                           ` Richard Biener
2019-11-13 14:41                             ` Jan Hubicka
2019-11-13 10:18                       ` Feng Xue OS
2019-11-13 14:47                         ` Martin Jambor
2019-11-15  8:10                         ` Jan Hubicka
2019-11-15 10:31                           ` Feng Xue OS
2019-11-15 14:16                             ` Jan Hubicka
2019-11-22 12:58                               ` Tamar Christina
2019-11-22 14:48                                 ` Jan Hubicka
2019-11-23 14:40                                   ` Tamar Christina
2019-11-23 15:21                                     ` Jan Hubicka
     [not found]                       ` <20191112124152.awcljza2432vnps3@kam.mff.cuni.cz>
2019-11-13 10:42                         ` Feng Xue OS
2019-10-15 16:12       ` [PATCH V4] " Philipp Tomsich
2019-10-16  8:24         ` Feng Xue OS

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=20191112132720.r5ralkbc6se5lc6v@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=fxue@os.amperecomputing.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mjambor@suse.cz \
    /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).