<div dir="ltr">The way I interpret Quentin's statement is something like:<div><br></div><div>- Inlining turns an interprocedural problem into an intraprocedural problem</div><div>- Outlining turns an intraprocedural problem into an interprocedural problem</div><div><br></div><div>Insofar as our intraprocedural analyses and transformations are strictly more powerful than interprocedural, then there is a precise sense in which inlining exposes optimization opportunities while outlining does not.</div><div><br></div><div>Actually, for his internship last summer River wrote a profile-guided outliner / partial inliner (it didn't try to do deduplication; so it was more like PartialInliner.cpp). IIRC he found that LLVM's interprocedural analyses were so bad that there were pretty adverse effects from many of the outlining decisions. E.g. if you outline from the left side of a diamond, that side basically becomes a black box to most LLVM analyses and forces downstream dataflow meet points to give an overly conservative result, even though our standard intraprocedural analyses would have happily dug through the left side of the diamond if the code had not been outlined.<br></div><div><br></div><div>Also, River's patch (the one in this thread) does parameterized outlining. For example, two sequences containing stores can be outlined even if the corresponding stores have different pointers. The pointer to be loaded from is passed as a parameter to the outlined function. In that sense, the outlined function's behavior becomes a conservative approximation of both which in principle loses precision.</div><div><br></div><div><br></div><div>I like your EarlyCSE example and it is interesting that combined with functionattrs it can make a "cheap" pass get a transformation that an "expensive" pass would otherwise be needed. Are there any cases where we only have the "cheap" pass and thus the outlining would be essential for our optimization pipeline to get the optimization right?</div><div><br></div><div>The case that comes to mind for me is cases where we have some cutoff of search depth. Reducing a sequence to a single call (+ functionattr inference) can essentially summarize the sequence and effectively increase search depth, which might give more results. That seems like a bit of a weak example though. </div><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 26, 2017 at 12:07 PM, Sanjoy Das via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
On Wed, Jul 26, 2017 at 10:10 AM, Quentin Colombet via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> No, I mean in terms of enabling other optimizations in the pipeline like<br>
> vectorizer. Outliner does not expose any of that.<br>
<br>
</span>I have not made a lot of effort to understand the full discussion here (so what<br>
I say below may be off-base), but I think there are some cases where outlining<br>
(especially working with function-attrs) can make optimization easier.<br>
<br>
It can help transforms that duplicate code (like loop unrolling and inlining) be<br>
more profitable -- I'm thinking of cases where unrolling/inlining would have to<br>
duplicate a lot of code, but after outlining would require duplicating only a<br>
few call instructions.<br>
<br>
<br>
It can help EarlyCSE do things that require GVN today:<br>
<br>
void foo() {<br>
  ... complex computation that computes func()<br>
  ... complex computation that computes func()<br>
}<br>
<br>
outlining=><br>
<br>
int func() { ... }<br>
<br>
void foo() {<br>
  int x = func();<br>
  int y = func();<br>
}<br>
<br>
functionattrs=><br>
<br>
int func() readonly { ... }<br>
<br>
void foo(int a, int b) {<br>
  int x = func();<br>
  int y = func();<br>
}<br>
<br>
earlycse=><br>
<br>
int func(int t) readnone { ... }<br>
<br>
void foo(int a, int b) {<br>
  int x = func(a);<br>
  int y = x;<br>
}<br>
<br>
GVN will catch this, but EarlyCSE is (at least supposed to be!) cheaper.<br>
<br>
<br>
Once we have an analysis that can prove that certain functions can't trap,<br>
outlining can allow LICM etc. to speculate entire outlined regions out of loops.<br>
<br>
<br>
Generally, I think outlining exposes information that certain regions of the<br>
program are doing identical things.  We should expect to get some mileage out of<br>
this information.<br>
<br>
-- Sanjoy<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>