[LLVMdev] Simplifying selects + arm stuff

Duncan Sands baldrick at free.fr
Thu Nov 11 07:43:56 PST 2010


Hi Chris,

>> We even have logic to do this (ThreadBinOpOverSelect, which I just added) in
>> InstructionSimplify.  The nice thing about InstructionSimplify is that it
>> doesn't ever create any new instructions, so is pretty much always a win.
>> The problem is that the logic never fires: your instcombine logic gets there
>> first, and transforms the example into
>>
>>   %z = select i1 %cond, i32 -1, i32 %x
>>   %s = and i32 %z, %y
>>   %r = and i32 %s, %x
>>
>> which is not nearly as good.
...
> Instead of turning this into a phase ordering issue, I'd rather increase the power of the folding logic to catch the general form.  In this case, instead of handling this in instsimplify, why not handle this in reassociate?
>
> This is conceptually no different than (x&  y&  x) ->  (x&  y), it's just that in this case you have: (x&  y&  (x or -1)) which should fold to (x&  y) just the same.

I actually came to the same conclusion, only since I didn't know about
the reassociate pass I planned to do this in instcombine :)  I will give
it a go.

Thanks for your help,

Duncan.



More information about the llvm-dev mailing list