Skip to content

Commit

Permalink
[SCEV] Remove conversion to SCEVUnionPredicate in ExitNotTakenInfo [NFC]
Browse files Browse the repository at this point in the history
This removes one of the places where we mutate an existing union predicate.
  • Loading branch information
preames committed Feb 9, 2022
1 parent f2f5e9f commit aa845d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/ScalarEvolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -1372,17 +1372,17 @@ class ScalarEvolution {
PoisoningVH<BasicBlock> ExitingBlock;
const SCEV *ExactNotTaken;
const SCEV *MaxNotTaken;
std::unique_ptr<SCEVUnionPredicate> Predicate;
SmallPtrSet<const SCEVPredicate *, 4> Predicates;

explicit ExitNotTakenInfo(PoisoningVH<BasicBlock> ExitingBlock,
const SCEV *ExactNotTaken,
const SCEV *MaxNotTaken,
std::unique_ptr<SCEVUnionPredicate> Predicate)
const SmallPtrSet<const SCEVPredicate *, 4> &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();
}
};

Expand Down
15 changes: 4 additions & 11 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down Expand Up @@ -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<SCEVUnionPredicate> 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<SCEVCouldNotCompute>(ConstantMax) ||
isa<SCEVConstant>(ConstantMax)) &&
Expand Down

0 comments on commit aa845d7

Please sign in to comment.