[PATCH] D53214: [X86][SSE] Change CTTZ vector lowering to cttz(x) = ctpop(~x & (x - 1))

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 13:11:41 PDT 2018


RKSimon created this revision.
RKSimon added reviewers: craig.topper, spatel, lebedev.ri, andreadb.

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 fit some issues with the bitcasted logic ops and CTPOP lowering first).


Repository:
  rL LLVM

https://reviews.llvm.org/D53214

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53214.169477.patch
Type: text/x-patch
Size: 232493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181012/5d26bcf0/attachment-0001.bin>


More information about the llvm-commits mailing list