File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -643,7 +643,10 @@ private extension MovableInstructions {
643643
644644 /// Hoist and sink scoped instructions.
645645 mutating func hoistWithSinkScopedInstructions( outOf loop: Loop , _ context: FunctionPassContext ) -> Bool {
646- guard !loop. hasNoExitBlocks else {
646+ // Since we don't sink scoped instructions to dead exit blocks, we need to check there's
647+ // at least one exit block to which we can sink end instructions. Otherwise we could end up
648+ // with partially hoisted scoped instruction that could lead to e.g. value overconsumption.
649+ guard !loop. hasNoExitBlocks, loop. exitBlocks. contains ( where: { !context. deadEndBlocks. isDeadEnd ( $0) } ) else {
647650 return false
648651 }
649652
You can’t perform that action at this time.
0 commit comments