Skip to content

Commit 55cdc31

Browse files
committed
LoopInvariantCodeMotion: a small refactoring
which is now possible as we removed the "fallthrough" from the previous case
1 parent e88096e commit 55cdc31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LoopInvariantCodeMotion.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,10 +1221,10 @@ private extension ScopedInstruction {
12211221
}
12221222
return true
12231223

1224-
case is BeginAccessInst:
1224+
case let beginAccess as BeginAccessInst:
12251225
for fullApplyInst in analyzedInstructions.fullApplies {
1226-
guard mayWriteToMemory && fullApplyInst.mayReadOrWrite(address: operands.first!.value, context.aliasAnalysis) ||
1227-
!mayWriteToMemory && fullApplyInst.mayWrite(toAddress: operands.first!.value, context.aliasAnalysis) else {
1226+
guard mayWriteToMemory && fullApplyInst.mayReadOrWrite(address: beginAccess.address, context.aliasAnalysis) ||
1227+
!mayWriteToMemory && fullApplyInst.mayWrite(toAddress: beginAccess.address, context.aliasAnalysis) else {
12281228
continue
12291229
}
12301230

@@ -1234,7 +1234,7 @@ private extension ScopedInstruction {
12341234
}
12351235
}
12361236

1237-
switch operands.first!.value.accessPath.base {
1237+
switch beginAccess.address.accessPath.base {
12381238
case .class, .global:
12391239
for sideEffect in analyzedInstructions.loopSideEffects where sideEffect.mayRelease {
12401240
// Since a class might have a deinitializer, hoisting begin/end_access pair could violate

0 commit comments

Comments
 (0)