Skip to content

Commit 55531ea

Browse files
authored
Merge pull request #67085 from hjyamauchi/licm
Don't try to hoist/sink {begin,end}_access when the loop has no exits
2 parents 6c19f3c + d7d55ec commit 55531ea

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SILOptimizer/LoopTransforms/LICM.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ hoistSpecialInstruction(std::unique_ptr<LoopNestSummary> &LoopSummary,
502502
bool Changed = false;
503503

504504
for (auto *Inst : Special) {
505+
if (isa<BeginAccessInst>(Inst) && LoopSummary->Loop->hasNoExitBlocks()) {
506+
// If no exit block, don't try to hoist BeginAccess because
507+
// sinking EndAccess would fail later.
508+
continue;
509+
}
505510
if (!hoistInstruction(DT, Inst, Loop, Preheader)) {
506511
continue;
507512
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swiftc_driver -O %s
2+
3+
// https://github.com/apple/swift/issues/67084
4+
// Don't crash failing to sink the corresponding end_access after
5+
// hoisting the begin_access when the loop has no exit.
6+
7+
var i = 0
8+
while true {
9+
i += 1
10+
}

0 commit comments

Comments
 (0)