diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 65c5d0e9f9c..edd46c5fe36 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1861,36 +1861,18 @@ static bool isKnownNonNullFromDominatingCondition(const Value *V, continue; for (auto *CmpU : U->users()) { - SmallVector<const User *, 4> WorkList; - SmallPtrSet<const User *, 4> Visited; - Visited.insert(CmpU); - WorkList.push_back(CmpU); - - while (!WorkList.empty()) { - auto *Curr = WorkList.pop_back_val(); - - // If a user is an AND, add all its users to the work list. - if (auto *BO = dyn_cast<BinaryOperator>(Curr)) - if (BO->getOpcode() == Instruction::And) { - for (auto *BOU : BO->users()) - if (Visited.insert(BOU).second) - WorkList.push_back(BOU); - continue; - } - - if (const BranchInst *BI = dyn_cast<BranchInst>(Curr)) { - assert(BI->isConditional() && "uses a comparison!"); + if (const BranchInst *BI = dyn_cast<BranchInst>(CmpU)) { + assert(BI->isConditional() && "uses a comparison!"); - BasicBlock *NonNullSuccessor = - BI->getSuccessor(Pred == ICmpInst::ICMP_EQ ? 1 : 0); - BasicBlockEdge Edge(BI->getParent(), NonNullSuccessor); - if (Edge.isSingleEdge() && DT->dominates(Edge, CtxI->getParent())) - return true; - } else if (Pred == ICmpInst::ICMP_NE && - match(Curr, m_Intrinsic<Intrinsic::experimental_guard>()) && - DT->dominates(cast<Instruction>(Curr), CtxI)) { + BasicBlock *NonNullSuccessor = + BI->getSuccessor(Pred == ICmpInst::ICMP_EQ ? 1 : 0); + BasicBlockEdge Edge(BI->getParent(), NonNullSuccessor); + if (Edge.isSingleEdge() && DT->dominates(Edge, CtxI->getParent())) return true; - } + } else if (Pred == ICmpInst::ICMP_NE && + match(CmpU, m_Intrinsic<Intrinsic::experimental_guard>()) && + DT->dominates(cast<Instruction>(CmpU), CtxI)) { + return true; } } } |