[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
Mon Jan 23 13:52:19 PST 2023


goldstein.w.n added a comment.

In D142271#4073849 <https://reviews.llvm.org/D142271#4073849>, @foad wrote:

> I suggest implementing this in new helper functions `KnownBits::blsi` and `KnownBits::blsmsk` (if we're happy with those names), plus comprehensive test coverage in `unittests/Support/KnownBitsTest.cpp`.

So started doing this. I realized, however, that what we really want is something like `computeKnownBitsFromAndXor`.

I think though doing all that in one patch is too much. Think it makes sense here to do the following:

1. Add the BMI patterns (this patch)
2. Factor our and/xor into common function (this will cleanup the BMI logics) + get the odd bit pattern for XOR
3. Going to apply this in simplifydemanded bits: https://reviews.llvm.org/D142300

So for this patch would prefer skipping adding into new functions as it will just be temporary anyways.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142271/new/

https://reviews.llvm.org/D142271



More information about the llvm-commits mailing list