[PATCH] D142271: [ValueTracking] Add KnownBits patterns `xor(x, x - 1)` and `and(x, -x)` for knowing upper bits to be zero

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 21:10:54 PST 2023


goldstein.w.n created this revision.
Herald added subscribers: foad, hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

These two BMI pattern will clear the upper bits of result past the
first set bit. So if we know a single bit in `x` is set, we know that
`results[bitwidth - 1, log2(x) + 1] = 0`.

Alive2:
blsmsk: https://alive2.llvm.org/ce/z/a397BS
blsi: https://alive2.llvm.org/ce/z/tsbQhC


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142271

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Analysis/ValueTracking/knownbits-bmi-pattern.ll
  llvm/test/Transforms/InstSimplify/ctpop-pow2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142271.491028.patch
Type: text/x-patch
Size: 15453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230121/1e3fd787/attachment.bin>


More information about the llvm-commits mailing list