<div dir="ltr">(and past this, i'm going to leave it alone. I have time for very little LLVM these days, and deep ingrained GVN issues ain't gonna be what i spend my little LLVM time on)<div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 5, 2017 at 1:54 PM Daniel Berlin <<a href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
I can't tell from your example enough detail to know what you're aiming for, but if there's a bug here, it's in replacing the add, not forming the phi node.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>I believe you have missed the point, so i'll make it a little later.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> patchAndReplaceAlluses will not remove the nsw from the phi in this case.<br>
>  We could teach it to do so.<br>
>  The other option is this patch, and fixing load PRE when it creates the phi in the first place.<br>
<br>
The phi is entirely correct and could be hand written.  If GVN is considering adds with different flags equivalent without appropriate backpatching, that's a bug in GVN's replacement.  </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">End of story.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Sure, but there is nowhere else to fix it.</div><div>When GVN does replacement, it assumes every instruction it is replacing with has already been fixed.</div><div>It has no way of saying "hey, somewhere in the chain of this instruction may be something you may have to fix later".</div><div><br></div><div>It is not recursive in patching at all.</div></div></div></blockquote></div>