<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 5, 2016 at 10:41 AM, David Callahan via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</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">david2050 added a comment.<br>
<br>
Regarding the question of simpler update to the control flow, I reviewed two references from @dberlin:<br>
<br>
(1)  <a href="https://www.clear.rice.edu/comp512/Lectures/10Dead-Clean-SCCP.pdf" rel="noreferrer" target="_blank">https://www.clear.rice.edu/<wbr>comp512/Lectures/10Dead-Clean-<wbr>SCCP.pdf</a><br>
<br>
In this work, the PHI nodes contain only references to named definitions and do not include a reference to the predecessor blocks associated with reaching paths from those definitions.<br></blockquote><div> </div><div>Yup, i'm not sure what the issue is that makes this harder :)</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
(2)  <a href="https://github.com/apple/swift/blob/master/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp" rel="noreferrer" target="_blank">https://github.com/apple/<wbr>swift/blob/master/lib/<wbr>SILOptimizer/Transforms/<wbr>DeadCodeElimination.cpp</a><br>
<br>
This swift variant makes no explicit reference to Phi nodes and does neither updates them nor manages explicit predecessors as far as I can tell.<br></blockquote><div>You keep saying explicit predecessors, but again, i'm not sure what the issue there is.</div><div>LLVM does not actually have explicit predecessors.</div><div>The predecessor iterators walk over the users of the basic block (which is a Value, and so has Uses/Users) to see which terminator instructions use it.</div><div>It then hands those blocks as predecessors.</div><div><br></div><div>So, for example, changing a *use* in a conditional branch updates the predecessors for the used block.</div><div><br></div><div>It's certainly true that this does not update phi nodes, which store explicit references, but that does not seem difficult to handle (since you can update them when you change the conditional branch, since at that point you know which phi nodes have edges that are about to change).</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Does anyone have another pointer to compiler which have SSA-based dead code elimination including control flow which might guide to a similar approach the code here?<br></blockquote><div><br></div><div>GCC has explicit edges, and phi nodes have explicit blocks.</div><div><a href="https://gcc.gnu.org/svn/gcc/trunk/gcc/tree-ssa-dce.c">https://gcc.gnu.org/svn/gcc/trunk/gcc/tree-ssa-dce.c</a><br></div><div>(ignore the virtual phi handling, which is memoryssa updating, not regular CFG updating).</div><div><br></div><div>Note it does not do anything amazingly difficult :)</div><div><br></div><div>In any case, this seems like one of those things where if we had a whiteboard in person, we could probably just solve  it in 10 minutes.</div><div><br></div><div>I don't think this should block the patch right now, since this is not heavily used or if you think this is too hard to do, let's just get this in and iterate on it in tree.</div><div><br></div><div><br></div><div><br></div></div></div></div>