From e2cbd13e5634e16301cd9e4b88b5ea08accafe9f Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 25 Apr 2016 17:23:36 +0000 Subject: [ValueTracking] Improve isImpliedCondition when the dominating cond is false. llvm-svn: 267430 --- llvm/lib/Analysis/ValueTracking.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Analysis/ValueTracking.cpp') diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 5ada78a5350..a9b8af1017c 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3962,8 +3962,8 @@ static Optional isImpliedCondMatchingOperands(CmpInst::Predicate APred, } Optional llvm::isImpliedCondition(Value *LHS, Value *RHS, - const DataLayout &DL, unsigned Depth, - AssumptionCache *AC, + const DataLayout &DL, bool InvertAPred, + unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) { assert(LHS->getType() == RHS->getType() && "mismatched type"); @@ -3971,7 +3971,7 @@ Optional llvm::isImpliedCondition(Value *LHS, Value *RHS, assert(OpTy->getScalarType()->isIntegerTy(1)); // LHS ==> RHS by definition - if (LHS == RHS) + if (!InvertAPred && LHS == RHS) return true; if (OpTy->isVectorTy()) @@ -3987,6 +3987,9 @@ Optional llvm::isImpliedCondition(Value *LHS, Value *RHS, !match(RHS, m_ICmp(BPred, m_Value(BLHS), m_Value(BRHS)))) return None; + if (InvertAPred) + APred = CmpInst::getInversePredicate(APred); + Optional Implication = isImpliedCondMatchingOperands(APred, ALHS, ARHS, BPred, BLHS, BRHS); if (Implication) -- cgit v1.2.3