<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;">Thanks Daniel & Tobias. <div>I think at this point limiting the number of checks and loads makes sense to play it safe for compile-time. </div><div><br></div><div><br></div><div>-Gerolf</div><div><br></div><div><br></div><div><br></div><div> <br><div><div>On Jun 18, 2014, at 1:47 PM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Wed, Jun 18, 2014 at 12:56 PM, Tobias Grosser <<a href="mailto:tobias@grosser.es">tobias@grosser.es</a>> wrote:<br><blockquote type="cite">On 18/06/2014 21:47, Daniel Berlin wrote:<br><blockquote type="cite"><br>FWIW: There is no easy way to do this O(n) for stores in LLVM, due to<br>the lack of something like memory-ssa (otherwise, you could sink to<br>the nearest common dominator of all immediate uses, as we do for GCC)<br>You can do it O(n),or much closer, in LLVM for loads, like this:<br><br>Assuming GVN and PRE has been run, all loads that can be determined to<br>be identical should look identical (if not, our GVN is seriously<br>busted :P) in their operands[1]<br><br>pending = hash table of <block, load operand> -> list of load instructions<br><br>for each load in the diamond:<br>  calculate sink location as nearest common dominator of:<br>     for each dependency according to memdep, the block of that<br>dependency<br>     for each RHS operand, the defining block of that operand.<br>  pending[<block, load operands>].insert(load instruction)<br><br>for each entry in pending:<br>if (list.size() > 1)<br>  Perform merge and hoist to end of common dominator block<br><br><br>This also would be even easier if GVN produced a value number or value<br>handle for each thing, like GCC's (then it wouldn't matter if they<br>looked identical, only if they calculate the same value), but c'est la<br>vie.<br><br>[1] The only case this wouldn't be true is if the load was defined by<br>operands in the diamond, in which case you couldn't hoist it out of<br>the diamond anyway without a real load PRE determining whether you<br>could move/recalculate the operands.<br></blockquote><br><br>Thanks Daniel!<br><br>Gerolf, even if we don't get this algorithm to a linear run-time, does it<br>make sense to bound the number of checks such that we don't get a quadratic<br>increase in compile time for those corner cases, but that we just don't<br>optimize them?<br></blockquote><br>+1<br>Little passes like this, created because other infrastructure<br>currently sucks and needs serious work, seem somewhat inevitable as<br>temporary things, but they do eat at compile time, so it's always good<br>to do what you can to limit impact, even if it means not catching<br>everything.<br><br><br><blockquote type="cite"><br>Tobias</blockquote></div></blockquote></div><br></div></body></html>