<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 5:55 PM, Ehsan Amiri <span dir="ltr"><<a href="mailto:amehsan@ca.ibm.com" target="_blank">amehsan@ca.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">amehsan added a comment.<br>
<br>
@dberlin<br>
<br>
I see two concerns in your comment:<br>
<span class=""><br>
> > Why not fix GVN to do that?<br>
<br>
><br>
<br>
><br>
<br>
><br>
<br>
<br>
</span>Before GVN this phi node has two different incoming values. At some point A in GVN, one of the incoming values change and we get the phi node in the example above. At some point B in the GVN, the phi node is removed. Somewhere between A and B, GVN makes an alias analysis query. So I think there is not really a problem in GVN to fix.<br></blockquote><div><br></div><div>I'm going to pretty strongly disagree.  If GVN expects AA to give it good intermediate answers, it needs to give AA good intermediate code.</div><div><br></div><div>GVN does a lot of simplification already. In fact, this would probably be one of the cheapest things GVN does It seems 100% trivial to make this work, unless you can show me it won't :)</div><div><br></div><div>Change:<br><div><br></div><div>   for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();</div><div>        BI != BE;) {</div><div>     if (!ReplaceWithConstMap.empty())</div><div>       ChangedFunction |= replaceOperandsWithConsts(&*BI);</div><div>     ChangedFunction |= processInstruction(&*BI);</div></div><div><br></div><div>To have a processPhiNode call at the beginning.</div><div>In processPhiNode, if all arguments are the same, RAUW with the phi node result.</div><div><br></div><div>Or heck, throw it in processInstruction</div><div><br></div><div>Now, if that doesn't work, or you have actual inter-pass examples where this is getting left around, sure, fine.</div><div>I want to avoid useless checks in alias analysis (and elsewhere) for non-canonical code.  </div><div><br></div><div>Look at it another way:<br><br></div><div>If this is common IR, every analysis is likely to need to do something with it, at some cost.</div><div><br></div><div>It's much cheaper to *not* have to process it at all, than have to process it everywhere.</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div></div></div></div>