[llvm-commits] [llvm] r123621 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/ctpop-combine.ll

Benjamin Kramer benny.kra at googlemail.com
Tue Jan 18 09:46:47 PST 2011


On 18.01.2011, at 18:29, Chris Lattner wrote:

> On Jan 18, 2011, at 7:38 AM, Benjamin Kramer wrote:
>>> This seems like an important loop!  One simple thing that I see is that we have:
>>> 
>>> ...
>>>      imulq   %r9, %r13
>>>      shrq    $56, %r13
>>> ...
>>>      imulq   %r9, %rbp
>>>      shrq    $56, %rbp
>>>      subl    %r13d, %ebp
>>> ...
>>>      cmpl    $2, %ebp
>>>      jne     LBB4_14
>>> 
>>> Is there some cheaper way to do ((x*0x101010101010101)>>56)-((y*0x101010101010101)>>56) != 2?
>> 
>> Applying distributive laws yields ((x-y)*0x101010101010101)>>56 != 2, however adding a
>> "machine distribution" pass just to catch this one feels like overkill.
> 
> Interesting! If that was safe then this could recursively simplify even more.  Is distribution safe across shifts though?  Instcombine doesn't simplify this, and doesn't simplify the similar code with add instead of sub:

No it's not, I was confused, shifts are not distributive even for unsigned integers :(



More information about the llvm-commits mailing list