// (including the PHI), except for the last value (which is used by the PHI
// and also outside the loop).
Instruction *C = Instructions.front();
+ if (C->user_empty())
+ return;
do {
C = cast<Instruction>(*C->user_begin());
if (Roots.empty())
return false;
-
- assert(Roots.find(0) == Roots.end() && "Didn't expect a zero index!");
// If we found non-loop-inc, non-root users of Base, assume they are
// for the zeroth root index. This is because "add %a, 0" gets optimized
// away.
- if (BaseUsers.size())
+ if (BaseUsers.size()) {
+ if (Roots.find(0) != Roots.end()) {
+ DEBUG(dbgs() << "LRR: Multiple roots found for base - aborting!\n");
+ return false;
+ }
Roots[0] = Base;
+ }
// Calculate the number of users of the base, or lowest indexed, iteration.
unsigned NumBaseUses = BaseUsers.size();
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
SE = &getAnalysis<ScalarEvolution>();
TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
- DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
- DL = DLP ? &DLP->getDataLayout() : nullptr;
+ DL = &L->getHeader()->getModule()->getDataLayout();
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
BasicBlock *Header = L->getHeader();