[PATCH] D76568: [InstCombine] Add CTPOP -> CTTZ simplifications (PR43513)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 22 09:36:22 PDT 2020


RKSimon created this revision.
RKSimon added reviewers: spatel, lebedev.ri, nikic, xbolva00.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

As detailed on PR43513, we can simplify:

ctpop(x | -x) -> bitwidth - cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/caw49X

ctpop(~x & (x - 1)) -> cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/5zfVrx

I've tweaked the initial test cases I added at rG2d712fb75584 <https://reviews.llvm.org/rG2d712fb75584ca8a6427199ca144407155e4b9b5> to increase commutativity testing, I'm happy to pre-commit these changes if you think its useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76568

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/ctpop-cttz.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76568.251898.patch
Type: text/x-patch
Size: 5126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200322/291f7124/attachment.bin>


More information about the llvm-commits mailing list