diff options
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index d381ee2..9458c89 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -279,16 +279,12 @@ bool llvm::haveNoCommonBitsSet(const Value *LHS, const Value *RHS, return KnownBits::haveNoCommonBitsSet(LHSKnown, RHSKnown); } -bool llvm::isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI) { - for (const User *U : CxtI->users()) { - if (const ICmpInst *IC = dyn_cast<ICmpInst>(U)) - if (IC->isEquality()) - if (Constant *C = dyn_cast<Constant>(IC->getOperand(1))) - if (C->isNullValue()) - continue; - return false; - } - return true; +bool llvm::isOnlyUsedInZeroEqualityComparison(const Instruction *I) { + // FIXME: Should not return true if there are no users. + return all_of(I->users(), [](const User *U) { + ICmpInst::Predicate P; + return match(U, m_ICmp(P, m_Value(), m_Zero())) && ICmpInst::isEquality(P); + }); } static bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth, |