diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-01-11 10:18:46 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-01-11 10:21:15 +0100 |
commit | cc845e9de8c87c74d494f4e90e8fcf4fca264989 (patch) | |
tree | 455984444a9ca41c0b4ee4b5127736450ac1b5e5 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 43cf2f8103f9ef0f292c2cd12e89c55406182e1a (diff) | |
download | llvm-cc845e9de8c87c74d494f4e90e8fcf4fca264989.zip llvm-cc845e9de8c87c74d494f4e90e8fcf4fca264989.tar.gz llvm-cc845e9de8c87c74d494f4e90e8fcf4fca264989.tar.bz2 |
[InstCombine] Handle assume(X & Pow2 != 0) in computeKnownBits()
If we know that X & Pow2 != 0, then the bit at that position is
known one.
Differential Revision: https://reviews.llvm.org/D140851
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 7c37b89..e49183d 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -940,6 +940,14 @@ static void computeKnownBitsFromAssume(const Value *V, KnownBits &Known, Known.Zero.setHighBits(RHSKnown.countMinLeadingZeros()); } break; + case ICmpInst::ICMP_NE: { + // assume (v & b != 0) where b is a power of 2 + const APInt *BPow2; + if (match(Cmp, m_ICmp(Pred, m_c_And(m_V, m_Power2(BPow2)), m_Zero())) && + isValidAssumeForContext(I, Q.CxtI, Q.DT)) { + Known.One |= BPow2->zextOrTrunc(BitWidth); + } + } break; } } |