<div class="gmail_quote">On 15 June 2011 10:37, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Wed, Jun 15, 2011 at 10:19 AM, Nick Lewycky <<a href="mailto:nlewycky@google.com">nlewycky@google.com</a>> wrote:<br>
>> > How about some calls to CombineTo?<br>
>><br>
>> You need a CombineTo call to handle the chain on the load.<br>
><br>
> Okay, but CombineTo is undocumented. It appears to be CombineTo(Old, New) to<br>
> replace Old with New, so I tried calling it with CombineTo(LN0, ExtLoad) but<br>
> that triggered the assert on the first line of CombineTo. Could you explain<br>
> a little more about what I need to do?<br>
<br>
</div>Err, try ReplaceAllUsesOfValueWith.<br></blockquote><div><br></div><div>It's almost ReplaceLoadWithPromotedLoad, but I need to use the Trunc value for more things. I ended up not doing this and going back to CombineTo.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">>> > Patch attached, please review! Carefully! ;)<br>
>><br>
>> Your use of ExtendUsesToFormExtLoad (and the !N0.hasOneUse() case in<br>
>> general) looks suspicious.<br>
><br>
> Cargo-culted from nearby. Look at the way "fold (zext (load x)) -> (zext<br>
> (truncate (zextload x)))" is handled. I think what's going on is that the<br>
> (load x) may have other uses, so the ExtendUsesToFormExtLoad function checks<br>
> whether inserting the necessary truncates would be free or the users could<br>
> be extended, etc.<br>
<br>
</div>Your current patch ends up duplicating the load; if you really want to<br>
handle the case where the loaded value has multiple uses, look at what<br>
the existing uses of ExtendUsesToFormExtLoad do.<br></blockquote><div><br></div><div>Okay, I pulled this thread and ended up refactoring. I've only tested the resulting patch on make check + the llvm nightly test suite, but I'm much closer to confident in its correctness. Updated patch attached.</div>

<div><br></div><div>Thanks for the review so far!</div><div><br></div><div>Nick</div><div><br></div></div>