// Information about the original loop we started out with.
Loop &OriginalLoop;
- const SCEV *LatchTakenCount = nullptr;
+ const IntegerType *ExitCountTy = nullptr;
BasicBlock *OriginalPreheader = nullptr;
// The preheader of the main loop. This may or may not be different from
FailureReason = "could not compute latch count";
return std::nullopt;
}
+ assert(SE.getLoopDisposition(LatchCount, &L) ==
+ ScalarEvolution::LoopInvariant &&
+ "loop variant exit count doesn't make sense!");
ICmpInst::Predicate Pred = ICI->getPredicate();
Value *LeftValue = ICI->getOperand(0);
}
BasicBlock *LatchExit = LatchBr->getSuccessor(LatchBrExitIdx);
- assert(SE.getLoopDisposition(LatchCount, &L) ==
- ScalarEvolution::LoopInvariant &&
- "loop variant exit count doesn't make sense!");
-
assert(!L.contains(LatchExit) && "expected an exit block!");
const DataLayout &DL = Preheader->getModule()->getDataLayout();
SCEVExpander Expander(SE, DL, "irce");
std::optional<LoopConstrainer::SubRanges>
LoopConstrainer::calculateSubRanges(bool IsSignedPredicate) const {
- IntegerType *Ty = cast<IntegerType>(LatchTakenCount->getType());
+ const IntegerType *Ty = ExitCountTy;
auto *RTy = cast<IntegerType>(Range.getType());
bool LoopConstrainer::run() {
BasicBlock *Preheader = nullptr;
- LatchTakenCount = SE.getExitCount(&OriginalLoop, MainLoopStructure.Latch);
+ const SCEV *LatchTakenCount =
+ SE.getExitCount(&OriginalLoop, MainLoopStructure.Latch);
Preheader = OriginalLoop.getLoopPreheader();
assert(!isa<SCEVCouldNotCompute>(LatchTakenCount) && Preheader != nullptr &&
"preconditions!");
+ ExitCountTy = cast<IntegerType>(LatchTakenCount->getType());
OriginalPreheader = Preheader;
MainLoopPreheader = Preheader;