[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
Tue Jan 24 11:28:31 PST 2023
goldstein.w.n added a comment.
In D142271#4077056 <https://reviews.llvm.org/D142271#4077056>, @foad wrote:
> 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`.
>
> I was thinking of something like D142469 <https://reviews.llvm.org/D142469>. Is this any use to you?
I see, yeah that makes sense although I would design it as a static API b.c we can technically get more information from `-x` or `x - 1` than `x` itself if it happens to match some assume.
I.e:
static KnownBits blsi(KnowBits X, KnownBits NegX) const;
static KnownBits blsmsk(KnowBits X, KnownBits XMinus1) const;
(Also realized there is a bug in the current impl as `XMinus1.One.countTrailingZeros()` can't be used for low bound.
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