[llvm-commits] patch: folding (zext (and x, cst))

Eli Friedman eli.friedman at gmail.com
Wed Jun 15 10:37:13 PDT 2011


On Wed, Jun 15, 2011 at 10:19 AM, Nick Lewycky <nlewycky at google.com> wrote:
>> > How about some calls to CombineTo?
>>
>> You need a CombineTo call to handle the chain on the load.
>
> Okay, but CombineTo is undocumented. It appears to be CombineTo(Old, New) to
> replace Old with New, so I tried calling it with CombineTo(LN0, ExtLoad) but
> that triggered the assert on the first line of CombineTo. Could you explain
> a little more about what I need to do?

Err, try ReplaceAllUsesOfValueWith.

>> > Patch attached, please review! Carefully! ;)
>>
>> Your use of ExtendUsesToFormExtLoad (and the !N0.hasOneUse() case in
>> general) looks suspicious.
>
> Cargo-culted from nearby. Look at the way "fold (zext (load x)) -> (zext
> (truncate (zextload x)))" is handled. I think what's going on is that the
> (load x) may have other uses, so the ExtendUsesToFormExtLoad function checks
> whether inserting the necessary truncates would be free or the users could
> be extended, etc.

Your current patch ends up duplicating the load; if you really want to
handle the case where the loaded value has multiple uses, look at what
the existing uses of ExtendUsesToFormExtLoad do.

-Eli



More information about the llvm-commits mailing list