<br><br><div class="gmail_quote">On Wed Nov 05 2014 at 4:49:47 PM Philip Reames <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
<br>
<div>On 10/24/2014 01:17 PM, Artem Dinaburg
wrote:<br>
</div>
<blockquote type="cite">
<pre>Hi,
It looks like the DeadStoreElimination optimization doesn't work across BasicBlock boundaries. The project I'm working on (<a href="https://github.com/trailofbits/mcsema" target="_blank">https://github.com/trailofbits/mcsema</a>), would tremendously benefit from even simple cross-block DSE. </pre>
</blockquote></div><div bgcolor="#FFFFFF" text="#000000">
If you have specific small examples which aren't getting caught, I'd
be interested in seeing test cases (as bugs.)
</div><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite">
<pre>There was a patch to do non-local DSE few years ago (<a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-January/028751.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-January/028751.html</a>), but seems that the patch was never merged.
Is there an existing way to do cross-block DSE?</pre>
</blockquote></div><div bgcolor="#FFFFFF" text="#000000">
EarlyCSE handles limited cases here. GVN probably could, but
doesn't seem to. (Which surprises me.)</div></blockquote><div><br></div><div>To do it "right", you'd have to build SSU and do PRE in the reverse direction, which GVN doesn't do. The patch posted actually does this "right" (building SSU and using it), though i haven't looked through it to see if it just does SSU building and usage, or actually does PRE. Either way, it's a good enough start :)</div><div><br></div><div>For normal cross-block cases, GVN does not value number loads *or* stores, so it will never discover this, unless it can do so through the load's direct dependency.</div><div><br></div><div>IMHO, cleaning up the SSU based patch and getting it in would be the right way to go. It may require some post-dominance speedups and cleanups to get it fast enough and right enough (I know everyone hates the post-dominator tree, but there is no other way to do proper store sinking)</div></div>