diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index 7c1c7e32f5633..07eb7678bc8cc 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1372,17 +1372,17 @@ class ScalarEvolution { PoisoningVH ExitingBlock; const SCEV *ExactNotTaken; const SCEV *MaxNotTaken; - std::unique_ptr Predicate; + SmallPtrSet Predicates; explicit ExitNotTakenInfo(PoisoningVH ExitingBlock, const SCEV *ExactNotTaken, const SCEV *MaxNotTaken, - std::unique_ptr Predicate) + const SmallPtrSet &Predicates) : ExitingBlock(ExitingBlock), ExactNotTaken(ExactNotTaken), - MaxNotTaken(ExactNotTaken), Predicate(std::move(Predicate)) {} + MaxNotTaken(ExactNotTaken), Predicates(Predicates) {} bool hasAlwaysTruePredicate() const { - return !Predicate || Predicate->isAlwaysTrue(); + return Predicates.empty(); } }; diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 620f3bf61af3a..1b270de4ed01d 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -7966,8 +7966,9 @@ ScalarEvolution::BackedgeTakenInfo::getExact(const Loop *L, ScalarEvolution *SE, Ops.push_back(BECount); - if (Preds && !ENT.hasAlwaysTruePredicate()) - Preds->add(ENT.Predicate.get()); + if (Preds) + for (auto *P : ENT.Predicates) + Preds->add(P); assert((Preds || ENT.hasAlwaysTruePredicate()) && "Predicate should be always true!"); @@ -8082,16 +8083,8 @@ ScalarEvolution::BackedgeTakenInfo::BackedgeTakenInfo( [&](const EdgeExitInfo &EEI) { BasicBlock *ExitBB = EEI.first; const ExitLimit &EL = EEI.second; - if (EL.Predicates.empty()) - return ExitNotTakenInfo(ExitBB, EL.ExactNotTaken, EL.MaxNotTaken, - nullptr); - - std::unique_ptr Predicate(new SCEVUnionPredicate); - for (auto *Pred : EL.Predicates) - Predicate->add(Pred); - return ExitNotTakenInfo(ExitBB, EL.ExactNotTaken, EL.MaxNotTaken, - std::move(Predicate)); + EL.Predicates); }); assert((isa(ConstantMax) || isa(ConstantMax)) &&