<div dir="ltr">(That comment applies mostly to newgvn).<div><br></div><div>In your case, i believe the code is just wrong:<br><br></div><div><div>/ This assumes the PHI is already well-formed and there aren't conflicting</div><div>    // incoming values for the same block.</div><div>    for (auto *B : Blocks)</div><div>      Values.push_back(PN->getIncomingValueForBlock(B))</div></div><div><br></div><div>It's 100% completely and definitely possible for a phi to have two values incoming from the same block, actually, regardless of whether it's a self block or not.</div><div>This happens using switch statements.</div><div>I believe we even have some testcases in newgvn for multiple edges from same incoming block.</div><div><br></div><div>So yeah, you have to handle them here.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 25, 2017 at 8:08 AM, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
----------------<br>
</span><span>dberlin wrote:<br>
> I'm curious why you think you need stable sort here as opposed to regular<br>
><br>
</span>I don't. Changed.<br>
<div class="m_-7927023127036086712HOEnZb"><div class="m_-7927023127036086712h5"><br></div></div></blockquote><div><br></div></span><div>(i'm offsite today, but someone should test this in newgvn too if i'm right).</div><div><br></div><div>Do we allow switch statements with multiple edges to ourself?<br><br>ie</div><div><br></div><div>bb1:<br><br>switch <whatever> [</div><div>i32 0 : label bb1</div><div>i32 1: label bb1 ]</div><div><br></div><div><br></div><div>(which, after propagation,  could cause a phi with different operands and the same incoming blocks)</div><div>If so, either we need stable sorts, or a better ordering of incoming blocks, because the pointer equality we use will not definitely sort them into a consistent order</div><div> </div></div></div></div>
</blockquote></div><br></div>