<div dir="ltr">I think this is going to be pretty much impossible to solve sanely in the current infrastructure.<div><br></div><div>Rather than try to make this more and more complicated, i would suggest we just step back and go with a variant on your original patch.</div><div><br></div><div>The attached should work (untested though, not on a computer with actual up to date llvm source ;P)</div><div>On Tue, Nov 17, 2015 at 6:00 PM, Weiming Zhao <span dir="ltr"><<a href="mailto:weimingz@codeaurora.org" target="_blank">weimingz@codeaurora.org</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">weimingz updated this revision to Diff 40465.<br>
weimingz added a comment.<br>
<br>
(this patch is mainly for discussion)<br>
<br>
Hi Berlin,<br>
<br>
Very appreciate for the explanation.<br>
My previous order about NextNum was indeed wrong, and thus addToLeaderTable was never executed, which masked the another problem:<br>
the newly created inst (%0) will get the VN before %sub.ptr.rhs.cast25. The NextNum check won’t prevent this.<br>
<br>
Looks like we should only assign numbers for new instrs that would have been visited (we only do make ups). For new instrs inserted in future points, we just leave it and wait for it to be processed naturally.<br>
But I can't find such support from existing GVN framework. I have an approximated solution in the patch.<br>
<br>
Any suggestions?<br>
<div class=""><div class="h5"><br>
<br>
<a href="http://reviews.llvm.org/D14670" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14670</a><br>
<br>
Files:<br>
  lib/Transforms/Scalar/GVN.cpp<br>
  test/Transforms/GVN/pr25440.ll<br>
<br>
</div></div></blockquote></div><br></div></div>