<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Apologies for delayed joining of this discussion, but I had a few notes from this thread that I really wanted to chime in about.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">River,</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">I don't mean to put you on the spot, but I do want to start on a semantic issue. In several places in the thread you used the words "we" and "our" to imply that you're not alone in writing this (which is totally fine), but your initial thread presented this as entirely your own work. So, when you said things like "we feel there's an advantage to being at the IR level", can you please clarify who is "we"?</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Given that there are a number of disagreements and opinions floating around I think it benefits us all to speak clearly about who is taking what stances.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">One particular disagreement that I think very much needs to be revisited in this thread was Jessica's proposal of a pipeline of:</div>
<ol class="">
<li style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">IR outline</li>
<li style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Inline</li>
<li style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">MIR outline</li></ol><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">In your response to that proposal you dismissed it out of hand with "feelings" but not data. Given that the proposal came from Jessica (a community member with significant relevant experience in outlining), and it was also recognized as interesting by Eric Christopher (a long-time member of the community with wide reaching expertise), I think dismissing it may have been a little premature.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">I also want to visit a few procedural notes.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Mehdi commented on the thread that it wouldn't be fair to ask for a comparative study because the MIR outliner didn't have one. While I don't think anyone is asking for a comparative study, I want to point out that I think it is completely fair. If a new contributor approached the community with a new SROA pass and wanted to land it in-tree it would be appropriate to ask for a comparative analysis against the existing pass. How is this different? </div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Adding a new IR outliner is a different situation from when the MIR one was added. When the MIR outliner was introduced there was no in-tree analog. When someone comes to the community with something that has no existing in-tree analog it isn't fair to necessarily ask them to implement it multiple different ways to prove their solution is the best. However, as a community, we do still exercise the right to reject contributions we disagree with, and we frequently request changes to the implementation (as is shown every time someone tries to add SPIR-V support).</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><div style="margin: 0px; line-height: normal;" class="">In the LLVM community we have a long history of approaching large contributions (especially ones from new contributors) with scrutiny and discussion. It would be a disservice to the project to forget that.</div></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69); min-height: 14px;" class="">River, as a last note. I see that you've started uploading patches to Phabricator, and I know you're relatively new to the community. When uploading patches it helps to include appropriate reviewers so that the right people see the patches as they come in. To that end can you please include Jessica as a reviewer? Given her relevant domain experience I think her feedback on the patches will be very valuable.</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">Thank you,</div><div style="margin: 0px; line-height: normal; color: rgb(69, 69, 69);" class="">-Chris</div><div style="margin: 0px; line-height: normal; font-family: 'Helvetica Neue'; color: rgb(69, 69, 69);" class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Jul 26, 2017, at 1:52 PM, River Riddle via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hey Sanjoy,<div class="">  </div><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 26, 2017 at 1:41 PM, Sanjoy Das via llvm-dev<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Hi,<br class=""><span class="gmail-"><br class="">On Wed, Jul 26, 2017 at 12:54 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" class="">chisophugis@gmail.com</a>> wrote:<br class="">> The way I interpret Quentin's statement is something like:<br class="">><br class="">> - Inlining turns an interprocedural problem into an intraprocedural problem<br class="">> - Outlining turns an intraprocedural problem into an interprocedural problem<br class="">><br class="">> Insofar as our intraprocedural analyses and transformations are strictly<br class="">> more powerful than interprocedural, then there is a precise sense in which<br class="">> inlining exposes optimization opportunities while outlining does not.<br class=""><br class=""></span>While I think our intra-proc optimizations are *generally* more<br class="">powerful, I don't think they are *always* more powerful.  For<br class="">instance, LICM (today) won't hoist full regions but it can hoist<br class="">single function calls.  If we can extract out a region into a<br class="">readnone+nounwind function call then LICM will hoist it to the<br class="">preheader if the safety checks pass.<br class=""><span class="gmail-"><br class="">> Actually, for his internship last summer River wrote a profile-guided<br class="">> outliner / partial inliner (it didn't try to do deduplication; so it was<br class="">> more like PartialInliner.cpp). IIRC he found that LLVM's interprocedural<br class="">> analyses were so bad that there were pretty adverse effects from many of the<br class="">> outlining decisions. E.g. if you outline from the left side of a diamond,<br class="">> that side basically becomes a black box to most LLVM analyses and forces<br class="">> downstream dataflow meet points to give an overly conservative result, even<br class="">> though our standard intraprocedural analyses would have happily dug through<br class="">> the left side of the diamond if the code had not been outlined.<br class="">><br class="">> Also, River's patch (the one in this thread) does parameterized outlining.<br class="">> For example, two sequences containing stores can be outlined even if the<br class="">> corresponding stores have different pointers. The pointer to be loaded from<br class="">> is passed as a parameter to the outlined function. In that sense, the<br class="">> outlined function's behavior becomes a conservative approximation of both<br class="">> which in principle loses precision.<br class=""><br class=""></span>Can we outline only once we've already done all of these optimizations<br class="">that outlining would block?<br class=""></blockquote><div class=""> </div><div class="">  The outliner is able to run at any point in the interprocedural pipeline. There are currently two locations: Early outlining(pre inliner) and late outlining(practically the last pass to run). It is configured to run either Early+Late, or just Late. </div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><span class="gmail-"><br class="">> I like your EarlyCSE example and it is interesting that combined with<br class="">> functionattrs it can make a "cheap" pass get a transformation that an<br class="">> "expensive" pass would otherwise be needed. Are there any cases where we<br class="">> only have the "cheap" pass and thus the outlining would be essential for our<br class="">> optimization pipeline to get the optimization right?<br class="">><br class="">> The case that comes to mind for me is cases where we have some cutoff of<br class="">> search depth. Reducing a sequence to a single call (+ functionattr<br class="">> inference) can essentially summarize the sequence and effectively increase<br class="">> search depth, which might give more results. That seems like a bit of a weak<br class="">> example though.<br class=""><br class=""></span>I don't know if River's patch outlines entire control flow regions at<br class="">a time, but if it does then we could use cheap basic block scanning<br class="">analyses for things that would normally require CFG-level analysis.<br class=""></blockquote><div class=""><br class=""></div><div class="">  The current patch currently just supports outlining from within a single block. Although, I had a working prototype for Region based outlining, I kept it from this patch for simplicity. So its entirely possible to add that kind of functionality because I've already tried.</div><div class="">Thanks,</div><div class="">  River Riddle</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><br class="">-- Sanjoy<br class=""><div class="gmail-HOEnZb"><div class="gmail-h5"><br class="">><br class="">> -- Sean Silva<br class="">><br class="">> On Wed, Jul 26, 2017 at 12:07 PM, Sanjoy Das via llvm-dev<br class="">> <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">>><br class="">>> Hi,<br class="">>><br class="">>> On Wed, Jul 26, 2017 at 10:10 AM, Quentin Colombet via llvm-dev<br class="">>> <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">>> > No, I mean in terms of enabling other optimizations in the pipeline like<br class="">>> > vectorizer. Outliner does not expose any of that.<br class="">>><br class="">>> I have not made a lot of effort to understand the full discussion here (so<br class="">>> what<br class="">>> I say below may be off-base), but I think there are some cases where<br class="">>> outlining<br class="">>> (especially working with function-attrs) can make optimization easier.<br class="">>><br class="">>> It can help transforms that duplicate code (like loop unrolling and<br class="">>> inlining) be<br class="">>> more profitable -- I'm thinking of cases where unrolling/inlining would<br class="">>> have to<br class="">>> duplicate a lot of code, but after outlining would require duplicating<br class="">>> only a<br class="">>> few call instructions.<br class="">>><br class="">>><br class="">>> It can help EarlyCSE do things that require GVN today:<br class="">>><br class="">>> void foo() {<br class="">>>   ... complex computation that computes func()<br class="">>>   ... complex computation that computes func()<br class="">>> }<br class="">>><br class="">>> outlining=><br class="">>><br class="">>> int func() { ... }<br class="">>><br class="">>> void foo() {<br class="">>>   int x = func();<br class="">>>   int y = func();<br class="">>> }<br class="">>><br class="">>> functionattrs=><br class="">>><br class="">>> int func() readonly { ... }<br class="">>><br class="">>> void foo(int a, int b) {<br class="">>>   int x = func();<br class="">>>   int y = func();<br class="">>> }<br class="">>><br class="">>> earlycse=><br class="">>><br class="">>> int func(int t) readnone { ... }<br class="">>><br class="">>> void foo(int a, int b) {<br class="">>>   int x = func(a);<br class="">>>   int y = x;<br class="">>> }<br class="">>><br class="">>> GVN will catch this, but EarlyCSE is (at least supposed to be!) cheaper.<br class="">>><br class="">>><br class="">>> Once we have an analysis that can prove that certain functions can't trap,<br class="">>> outlining can allow LICM etc. to speculate entire outlined regions out of<br class="">>> loops.<br class="">>><br class="">>><br class="">>> Generally, I think outlining exposes information that certain regions of<br class="">>> the<br class="">>> program are doing identical things.  We should expect to get some mileage<br class="">>> out of<br class="">>> this information.<br class="">>><br class="">>> -- Sanjoy<br class="">>> ______________________________<wbr class="">_________________<br class="">>> LLVM Developers mailing list<br class="">>><span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">>><span class="Apple-converted-space"> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">><br class="">><br class="">______________________________<wbr class="">_________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class=""></div></div></blockquote></div><br class=""></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div><br class=""></body></html>