<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
[+my non-arm account]
<div class=""><br class="">
</div>
<div class="">Hi,</div>
<div class=""><br class="">
</div>
<div class="">I believe I have a testcase for that too. The key is the word “conflicting” - we can have multiple edges from the same predecessor, but to be well formed all phi values for those arcs must be the same. The verifier checks this, if I recall.</div>
<div class=""><br class="">
</div>
<div class="">I’ll make sure there’s a testcase at least for the full expected behaviour (this pass is off by default at the moment so there’s no panic about trunk miscompiling).</div>
<div class=""><br class="">
</div>
<div class="">James</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 25 May 2017, at 16:11, Daniel Berlin <<a href="mailto:dberlin@dberlin.org" class="">dberlin@dberlin.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">(That comment applies mostly to newgvn).
<div class=""><br class="">
</div>
<div class="">In your case, i believe the code is just wrong:<br class="">
<br class="">
</div>
<div class="">
<div class="">/ This assumes the PHI is already well-formed and there aren't conflicting</div>
<div class="">    // incoming values for the same block.</div>
<div class="">    for (auto *B : Blocks)</div>
<div class="">      Values.push_back(PN->getIncomingValueForBlock(B))</div>
</div>
<div class=""><br class="">
</div>
<div class="">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 class="">This happens using switch statements.</div>
<div class="">I believe we even have some testcases in newgvn for multiple edges from same incoming block.</div>
<div class=""><br class="">
</div>
<div class="">So yeah, you have to handle them here.</div>
<div class=""><br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Thu, May 25, 2017 at 8:08 AM, Daniel Berlin <span dir="ltr" class="">
<<a href="mailto:dberlin@dberlin.org" target="_blank" class="">dberlin@dberlin.org</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<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 class=""><br class="">
----------------<br class="">
</span><span class="">dberlin wrote:<br class="">
> I'm curious why you think you need stable sort here as opposed to regular<br class="">
><br class="">
</span>I don't. Changed.<br class="">
<div class="m_-7927023127036086712HOEnZb">
<div class="m_-7927023127036086712h5"><br class="">
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
</span>
<div class="">(i'm offsite today, but someone should test this in newgvn too if i'm right).</div>
<div class=""><br class="">
</div>
<div class="">Do we allow switch statements with multiple edges to ourself?<br class="">
<br class="">
ie</div>
<div class=""><br class="">
</div>
<div class="">bb1:<br class="">
<br class="">
switch <whatever> [</div>
<div class="">i32 0 : label bb1</div>
<div class="">i32 1: label bb1 ]</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">(which, after propagation,  could cause a phi with different operands and the same incoming blocks)</div>
<div class="">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 class=""> </div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
 or store or copy the information in any medium. Thank you.
</body>
</html>