OSDN Git Service

[X86][SSE] Change CTTZ vector lowering to cttz(x) = ctpop(~x & (x - 1))
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 13 Oct 2018 12:12:06 +0000 (12:12 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 13 Oct 2018 12:12:06 +0000 (12:12 +0000)
commite76d7099025f36d5c09a44404756b1f41f55af96
treea6a316ba912ae2ae16497da2ae84b404aa1ea800
parent0f13604417ac2a666797fa40530a3164ba917a7d
[X86][SSE] Change CTTZ vector lowering to cttz(x) = ctpop(~x & (x - 1))

This patch changes the vector CTTZ lowering from:

cttz(x) = ctpop((x & -x) - 1)

to:

cttz(x) = ctpop(~x & (x - 1))

Not only does this make better use of the PANDN instruction, but it also matches the LegalizeDAG method which should allow us to remove the x86 specific code at some point in the future (we need to fix some issues with the bitcasted logic ops and CTPOP lowering first).

Differential Revision: https://reviews.llvm.org/D53214

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344447 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/vec_ctbits.ll
test/CodeGen/X86/vector-tzcnt-128.ll
test/CodeGen/X86/vector-tzcnt-256.ll
test/CodeGen/X86/vector-tzcnt-512.ll