Skip to content

Commit 7c2c047

Browse files
committed
LoopUtils: Remove useless canonicalization.
1 parent 8346156 commit 7c2c047

File tree

1 file changed

+1
-58
lines changed

1 file changed

+1
-58
lines changed

lib/SILOptimizer/Utils/LoopUtils.cpp

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -169,61 +169,6 @@ static SILBasicBlock *insertBackedgeBlock(SILLoop *L, DominanceInfo *DT,
169169
return BEBlock;
170170
}
171171

172-
/// Canonicalize loop exit blocks so that they only have predecessors inside the
173-
/// loop.
174-
static bool canonicalizeLoopExitBlocks(SILLoop *L, DominanceInfo *DT,
175-
SILLoopInfo *LI) {
176-
assert(L && "We assume that L is not null");
177-
178-
bool Changed = false;
179-
SmallVector<SILBasicBlock *, 8> ExitingBlocks;
180-
L->getExitingBlocks(ExitingBlocks);
181-
182-
for (auto *ExitingBlock : ExitingBlocks) {
183-
for (unsigned i : indices(ExitingBlock->getSuccessors())) {
184-
// We have to look up our exiting blocks each time around the loop since
185-
// if we split a critical edge, the exiting block will have a new
186-
// terminator implying a new successor list. The new non-critical edge
187-
// though will be placed at the same spot in the new terminator where the
188-
// critical edge was in the old terminator. Thus as long as we use
189-
// indices, we will visit all exiting block edges appropriately and not
190-
// deal with touching stale memory.
191-
auto Succs = ExitingBlock->getSuccessors();
192-
auto *SuccBB = Succs[i].getBB();
193-
194-
// Add only exit block successors by skipping blocks in the loop.
195-
if (LI->getLoopFor(SuccBB) == L)
196-
continue;
197-
198-
// This is unfortunate but necessary since splitCriticalEdge may change IDs.
199-
#ifndef NDEBUG
200-
llvm::SmallString<5> OldExitingBlockName;
201-
LLVM_DEBUG({
202-
llvm::raw_svector_ostream buffer(OldExitingBlockName);
203-
ExitingBlock->printAsOperand(buffer);
204-
});
205-
llvm::SmallString<5> OldSuccBBName;
206-
LLVM_DEBUG({
207-
llvm::raw_svector_ostream buffer(OldSuccBBName);
208-
SuccBB->printAsOperand(buffer);
209-
});
210-
#endif
211-
212-
// Split any critical edges in between exiting block and succ iter.
213-
if (splitCriticalEdge(ExitingBlock->getTerminator(), i, DT, LI)) {
214-
LLVM_DEBUG(llvm::dbgs() << "Split critical edge from "
215-
<< OldExitingBlockName << " NewID: ";
216-
ExitingBlock->printAsOperand(llvm::dbgs());
217-
llvm::dbgs() << " -> OldID: " << OldSuccBBName << " NewID: ";
218-
SuccBB->printAsOperand(llvm::dbgs()); llvm::dbgs() << "\n");
219-
Changed = true;
220-
}
221-
}
222-
}
223-
224-
return Changed;
225-
}
226-
227172
/// Canonicalize the loop for rotation and downstream passes.
228173
///
229174
/// Create a single preheader and single latch block.
@@ -232,14 +177,12 @@ static bool canonicalizeLoopExitBlocks(SILLoop *L, DominanceInfo *DT,
232177
/// them before merging the latch. See LLVM's separateNestedLoop.
233178
bool swift::canonicalizeLoop(SILLoop *L, DominanceInfo *DT, SILLoopInfo *LI) {
234179
bool ChangedCFG = false;
180+
235181
if (!L->getLoopPreheader()) {
236182
insertPreheader(L, DT, LI);
237183
assert(L->getLoopPreheader() && "L should have a pre-header now");
238184
ChangedCFG = true;
239185
}
240-
241-
ChangedCFG |= canonicalizeLoopExitBlocks(L, DT, LI);
242-
243186
if (!L->getLoopLatch())
244187
ChangedCFG |= (insertBackedgeBlock(L, DT, LI) != nullptr);
245188

0 commit comments

Comments
 (0)