<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>I believe you have missed the point, so i'll make it a little later.</div><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>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>