[PATCH] D63660: [InstCombine] squash is-power-of-2 that uses ctpop

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 11:16:46 PDT 2019


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

This is another intermediate IR step towards solving PR42314:
https://bugs.llvm.org/show_bug.cgi?id=42314

We can test if a value is power-of-2-or-0 using ctpop(X) < 2, so combining that with a non-zero check of the input is the same as testing if exactly 1 bit is set:

  (X != 0) && (ctpop(X) u< 2) --> ctpop(X) == 1


https://reviews.llvm.org/D63660

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/test/Transforms/InstCombine/ispow2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63660.206036.patch
Type: text/x-patch
Size: 4795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190621/27d78bb8/attachment.bin>


More information about the llvm-commits mailing list