Skip to content

Commit 64e202e

Browse files
committed
Revert "Fix aliasing DestroyAddrInst with load borrow. Enable speculative scoped instruction hoisting."
This reverts commit b50d466.
1 parent b50d466 commit 64e202e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LoopInvariantCodeMotion.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,10 @@ private extension MovableInstructions {
647647
return false
648648
}
649649

650+
let dominatingBlocks = loop.getBlocksThatDominateAllExitingAndLatchBlocks(context)
650651
var changed = false
651652

652-
for scopedInst in scopedInsts {
653+
for scopedInst in scopedInsts where dominatingBlocks.contains(scopedInst.parentBlock) {
653654
guard scopedInst.hoist(outOf: loop, context) else {
654655
continue
655656
}
@@ -1106,9 +1107,9 @@ private extension ScopedInstruction {
11061107
case is BeginApplyInst:
11071108
return true // Has already been checked with other full applies.
11081109
case is LoadBorrowInst:
1109-
for inst in loop.loopBlocks.lazy.flatMap(\.instructions) {
1110-
if (inst is DestroyAddrInst || inst is StoreInst) && inst.operands.contains(where: { context.aliasAnalysis.mayAlias(operands.first!.value, $0.value) }) {
1111-
if !scope.contains(inst) {
1110+
for storeInst in analyzedInstructions.stores {
1111+
if storeInst.mayWrite(toAddress: operands.first!.value, context.aliasAnalysis) {
1112+
if !scope.contains(storeInst) {
11121113
return false
11131114
}
11141115
}

0 commit comments

Comments
 (0)