[llvm-commits] [llvm] r123621 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/ctpop-combine.ll
Chris Lattner
clattner at apple.com
Tue Jan 18 09:51:43 PST 2011
On Jan 18, 2011, at 9:46 AM, Benjamin Kramer wrote:
>
> 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 :(
The only cleverness I can come up with is something like:
((x - (y & (-1 << 56))) >> 56) & 255
This is the same number of operations, but the &255 can be done implicitly with subreg tricks on X86. I don't think that this is worth implementing though.
-Chris
More information about the llvm-commits
mailing list