Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions llvm/lib/Transforms/Scalar/LoopInterchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,18 +511,8 @@ struct LoopInterchange {
for (unsigned j = SelecLoopId; j > 0; j--) {
bool ChangedPerIter = false;
for (unsigned i = SelecLoopId; i > SelecLoopId - j; i--) {
bool Interchanged = processLoop(LoopList[i], LoopList[i - 1], i, i - 1,
DependencyMatrix, CostMap);
if (!Interchanged)
continue;
// Loops interchanged, update LoopList accordingly.
std::swap(LoopList[i - 1], LoopList[i]);
// Update the DependencyMatrix
interChangeDependencies(DependencyMatrix, i, i - 1);

LLVM_DEBUG(dbgs() << "Dependency matrix after interchange:\n";
printDepMatrix(DependencyMatrix));

bool Interchanged =
processLoop(LoopList, i, i - 1, DependencyMatrix, CostMap);
ChangedPerIter |= Interchanged;
Changed |= Interchanged;
}
Expand All @@ -534,10 +524,12 @@ struct LoopInterchange {
return Changed;
}

bool processLoop(Loop *InnerLoop, Loop *OuterLoop, unsigned InnerLoopId,
bool processLoop(SmallVectorImpl<Loop *> &LoopList, unsigned InnerLoopId,
unsigned OuterLoopId,
std::vector<std::vector<char>> &DependencyMatrix,
const DenseMap<const Loop *, unsigned> &CostMap) {
Loop *OuterLoop = LoopList[OuterLoopId];
Loop *InnerLoop = LoopList[InnerLoopId];
LLVM_DEBUG(dbgs() << "Processing InnerLoopId = " << InnerLoopId
<< " and OuterLoopId = " << OuterLoopId << "\n");
LoopInterchangeLegality LIL(OuterLoop, InnerLoop, SE, ORE);
Expand Down Expand Up @@ -566,6 +558,15 @@ struct LoopInterchange {
LoopsInterchanged++;

llvm::formLCSSARecursively(*OuterLoop, *DT, LI, SE);

// Loops interchanged, update LoopList accordingly.
std::swap(LoopList[OuterLoopId], LoopList[InnerLoopId]);
// Update the DependencyMatrix
interChangeDependencies(DependencyMatrix, InnerLoopId, OuterLoopId);

LLVM_DEBUG(dbgs() << "Dependency matrix after interchange:\n";
printDepMatrix(DependencyMatrix));

return true;
}
};
Expand Down