[PATCH] D55669: [LIR] Add CTTZ support

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 13 13:21:33 PST 2018


tabloid.adroit created this revision.
Herald added a subscriber: llvm-commits.

Existing LIR recognizes CTLZ where shifting input variable right until it is zero. (Shift-Until-Zero idiom)

This commit:

1. augment Shift-Until-Zero idiom to recognize CTTZ where input variable is shifted left.
2. Add a second idiom recognition (BitScan idiom) where bits of input variable are scanned in order until hit a set bit: scan-from-left-to-right means CTLZ; scan-from-right-to-left means CTTZ. The starting bit index do not have to be first bit if we could prove from CFG that preceding bits are zero.

Related PR: llvm.org/PR17087


Repository:
  rL LLVM

https://reviews.llvm.org/D55669

Files:
  lib/Transforms/Scalar/LoopIdiomRecognize.cpp
  test/Transforms/LoopIdiom/X86/ctlz.ll
  test/Transforms/LoopIdiom/X86/cttz.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55669.178125.patch
Type: text/x-patch
Size: 51894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181213/bf112c53/attachment.bin>


More information about the llvm-commits mailing list