<html><body><p>Sure, I will attach it shortly.<br><br><img width="16" height="16" src="cid:1__=8FBBF563DFE350A48f9e8a93df938690918c8FB@" border="0" alt="Inactive hide details for Daniel Berlin ---07/14/2016 04:27:43 PM---Actually, can you please attach a .ll file and an opt comma"><font color="#424282">Daniel Berlin ---07/14/2016 04:27:43 PM---Actually, can you please attach a .ll file and an opt command line that reproduces the problem?</font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">Daniel Berlin <dberlin@dberlin.org></font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Ehsan A Amiri/Toronto/IBM@IBMCA</font><br><font size="2" color="#5F5F5F">Cc:        </font><font size="2">Hal Finkel <hfinkel@anl.gov>, llvm-commits <llvm-commits@lists.llvm.org>, reviews+D22305+public+92ca108e50bc4651@reviews.llvm.org</font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">07/14/2016 04:27 PM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: [PATCH] D22305: [BasicAA] Strip phi nodes, when all incoming values are the same.</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br><font size="4">Actually, can you please attach a .ll file and an opt command line that reproduces the problem?<br>The clang command line you have is very sensitive to versions, etc.</font><br><br><font size="4">I cannot get your issue to reproduce with the clang i have installed that can target powerpc-linux (and the issue does not reproduce with your testcase on x86) :)</font><br><br><font size="4">While debugging a bit, note that there is at least one obvious bug in GVN that may affect this, by inspection:</font><br><br><font size="4">When GVN splits a critical edge, it never adds the new block to the iteration order (at all), even though it inserts into it.</font><br><font size="4">So they will not get processed until the next iteration of GVN on the function, even though they have code in them.  While this is okay from a correctness standpoint, it may block optimization of certain things (including the cases you've discovered).  In practice, there is no way to perfectly solve that without pre-splitting all critical edges, but you should get the same effect if we throw the critical edge block and then it's successors (including the current blcok) into bbvect after the current block again.</font><br><br><font size="4">It is also missing a real phi simplification.</font><br><font size="4">While simplifyinstruction will check if all arguments are trivially the same, that is not the real test that should be performed.</font><br><br><font size="4">It should be doing VN.lookup on each argument and seeing if they come up with the the same value number.</font><br><br><font size="4">Once you attach the .ll file, i'll fix these and see if it fixes your testcase, and if not, debug further.</font><br><br><br><font size="4">On Thu, Jul 14, 2016 at 10:11 AM, Daniel Berlin <</font><a href="mailto:dberlin@dberlin.org" target="_blank"><u><font size="4" color="#0000FF">dberlin@dberlin.org</font></u></a><font size="4">> wrote:</font><ul><br><br><font size="4">On Thu, Jul 14, 2016 at 7:09 AM, Ehsan A Amiri <</font><a href="mailto:amehsan@ca.ibm.com" target="_blank"><u><font size="4" color="#0000FF">amehsan@ca.ibm.com</font></u></a><font size="4">> wrote:</font><br><font size="4">This is order of events:<br></font><p><font size="4">This order cannot be correct if the solution I gave (or adding simplification to *some place in GVN*) does not work.  Or GVN is broken in other ways.</font><br><font size="4"> </font><br><font size="4">1) GVN starts looking at the function. At this point the phi node has two different incoming values.<br>2) GVN performs an RAUW. The phi is converted to the one that has two identincal incoming values. </font><p><br><font size="4">At this point, it should now process the phi instruction again before it processes the load, because it is doing a reverse postorder traversal.</font><br><font size="4">When it did that, the phi should have been simplified</font><br><font size="4">So why did that not happen?</font><br><br><font size="4">Given the complexity of fixing the real problem,</font><p><br><font size="4">Look, i understand why you want to just fix this in AA and be done with it.</font><br><font size="4">Really, I do. </font><br><br><font size="4">I understand you have spent a lot of time on this bug, and I greatly appreciate that.</font><br><font size="4">But I really want to understand what is going on before we try to actually fix it.</font><br><font size="4">I have a good understanding of what happens once the bad answer gets into memdep (and thank you for that!), but i still have trouble seeing why it lived long enough to get there.</font><br><br><font size="4">To that end, so you don't have to spend more time running around for me,  i'll take over this bug, and either figure out why GVN lets this PHI live to the point it gets an AA query about it (and fix it/decide it can't be fixed), or commit the AA patch for you if we decide it can't be fixed.</font><br><br><font size="4">My ETA is by friday.</font><br><br><font size="4">I assume the testcase in the bug is the one we are still using, right?<br>(If not, if you can attach it, that would be helpful)</font><br><br></ul><br><BR>
</body></html>