Skip to content

Commit 8346156

Browse files
committed
LoopRotate: Avoid introducing new critical edges during rotation.
1 parent 223ee10 commit 8346156

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/SILOptimizer/LoopTransforms/LoopRotate.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,13 @@ bool swift::rotateLoop(SILLoop *loop, DominanceInfo *domInfo,
409409
header->moveAfter(latch);
410410

411411
// Merge the old latch with the old header if possible.
412-
mergeBasicBlockWithSuccessor(latch, domInfo, loopInfo);
412+
if (mergeBasicBlockWithSuccessor(latch, domInfo, loopInfo))
413+
newHeader = latch; // The old Header is gone. Latch is now the Header.
413414

414-
// Create a new preheader.
415-
splitIfCriticalEdge(preheader, newHeader, domInfo, loopInfo);
415+
// Cloning the header into the preheader created critical edges from the
416+
// preheader and original header to both the new header and loop exit.
417+
splitCriticalEdgesFrom(preheader, domInfo, loopInfo);
418+
splitCriticalEdgesFrom(newHeader, domInfo, loopInfo);
416419

417420
if (shouldVerify) {
418421
domInfo->verify();

0 commit comments

Comments
 (0)