Skip to content

Commit 84a24a8

Browse files
committed
Simplify end_borrow creation.
1 parent b115e24 commit 84a24a8

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LoopInvariantCodeMotion.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ private func collectMovableInstructions(
334334
movableInstructions.scopedInsts.append(beginBorrowInst)
335335
}
336336
case let fullApplySite as FullApplySite:
337-
// TODO: Use set for this check.
338337
guard analyzedInstructions.readOnlyApplies.contains(where: { $0 == fullApplySite }) else {
339338
break
340339
}
@@ -904,16 +903,11 @@ private extension Instruction {
904903
let copyValue = headerBuilder.createCopyValue(operand: preheaderLoadBorrow)
905904
loadCopyInst.replace(with: copyValue, context)
906905

907-
var createdEndBorrow: EndBorrowInst?
908906
for exitBlock in loop.exitBlocks where !context.deadEndBlocks.isDeadEnd(exitBlock) {
909907
assert(exitBlock.hasSinglePredecessor, "Exiting edge should not be critical.")
910908

911-
if let createdEndBorrow {
912-
createdEndBorrow.copy(before: exitBlock.instructions.first!, context)
913-
} else {
914-
let exitBlockBuilder = Builder(before: exitBlock.instructions.first!, context)
915-
createdEndBorrow = exitBlockBuilder.createEndBorrow(of: preheaderLoadBorrow)
916-
}
909+
let exitBlockBuilder = Builder(before: exitBlock.instructions.first!, context)
910+
exitBlockBuilder.createEndBorrow(of: preheaderLoadBorrow)
917911
}
918912
}
919913

0 commit comments

Comments
 (0)