using IntervalMap = DenseMap<Instruction *, unsigned>;
// Maps instruction to its index.
- DenseMap<unsigned, Instruction *> IdxToInstr;
+ SmallVector<Instruction *, 64> IdxToInstr;
// Marks the end of each interval.
IntervalMap EndPoint;
// Saves the list of instruction indices that are used in the loop.
// defined outside the loop, such as arguments and constants.
SmallPtrSet<Value *, 8> LoopInvariants;
- unsigned Index = 0;
for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO())) {
for (Instruction &I : BB->instructionsWithoutDebug()) {
- IdxToInstr[Index++] = &I;
+ IdxToInstr.push_back(&I);
// Save the end location of each USE.
for (Value *U : I.operands()) {
}
// Overwrite previous end points.
- EndPoint[Instr] = Index;
+ EndPoint[Instr] = IdxToInstr.size();
Ends.insert(Instr);
}
}
return std::max<unsigned>(1, VF * TypeSize / WidestRegister);
};
- for (unsigned int i = 0; i < Index; ++i) {
+ for (unsigned int i = 0, s = IdxToInstr.size(); i < s; ++i) {
Instruction *I = IdxToInstr[i];
// Remove all of the instructions that end at this location.