[PATCH] D63777: [InstCombine] reduce checks for power-of-2-or-zero using ctpop

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 09:57:33 PDT 2019


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

This follows up the transform from rL363956 <https://reviews.llvm.org/rL363956> to use the ctpop intrinsic when checking for power-of-2-or-zero.

This is matching the isPowerOf2() patterns used in PR42314:
https://bugs.llvm.org/show_bug.cgi?id=42314

But there's at least 1 instcombine follow-up needed to match the alternate form:

  (v & (v - 1)) == 0;

We should have all of the backend expansions handled with:
rL364319 <https://reviews.llvm.org/rL364319>
(x86-specific changes still needed for optimal code based on subtarget)

And the larger patterns to exclude zero as a power-of-2 are joining with this change after:
rL364153 <https://reviews.llvm.org/rL364153> ( D63660 <https://reviews.llvm.org/D63660> )
rL364246 <https://reviews.llvm.org/rL364246>


https://reviews.llvm.org/D63777

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63777.206469.patch
Type: text/x-patch
Size: 9187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190625/2968338e/attachment-0001.bin>


More information about the llvm-commits mailing list