Skip to content

Commit 73ee38c

Browse files
committed
Add tracing to LICM for reloaded store/restored load optimization.
1 parent 5f17f5b commit 73ee38c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/SILOptimizer/LoopTransforms/LICM.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ void LoopTreeOptimization::hoistLoadsAndStores(SILValue addr, SILLoop *loop, Ins
10151015
SILBuilder B(preheader->getTerminator());
10161016
auto *initialLoad = B.createLoad(preheader->getTerminator()->getLoc(), addr,
10171017
LoadOwnershipQualifier::Unqualified);
1018+
LLVM_DEBUG(llvm::dbgs() << "Creating preload " << *initialLoad);
10181019

10191020
SILSSAUpdater ssaUpdater;
10201021
ssaUpdater.Initialize(initialLoad->getType());
@@ -1047,6 +1048,7 @@ void LoopTreeOptimization::hoistLoadsAndStores(SILValue addr, SILLoop *loop, Ins
10471048
currentVal = SILValue();
10481049
}
10491050
if (auto *SI = isStoreToAddr(I, addr)) {
1051+
LLVM_DEBUG(llvm::dbgs() << "Deleting reloaded store " << *SI);
10501052
currentVal = SI->getSrc();
10511053
toDelete.push_back(SI);
10521054
} else if (auto *LI = isLoadFromAddr(I, addr)) {
@@ -1056,6 +1058,8 @@ void LoopTreeOptimization::hoistLoadsAndStores(SILValue addr, SILLoop *loop, Ins
10561058
currentVal = ssaUpdater.GetValueInMiddleOfBlock(block);
10571059
SILValue projectedValue = projectLoadValue(LI->getOperand(), addr,
10581060
currentVal, LI);
1061+
LLVM_DEBUG(llvm::dbgs() << "Replacing stored load " << *LI << " with "
1062+
<< projectedValue);
10591063
LI->replaceAllUsesWith(projectedValue);
10601064
toDelete.push_back(LI);
10611065
}
@@ -1068,8 +1072,11 @@ void LoopTreeOptimization::hoistLoadsAndStores(SILValue addr, SILLoop *loop, Ins
10681072
assert(succ->getSinglePredecessorBlock() &&
10691073
"should have split critical edges");
10701074
SILBuilder B(succ->begin());
1071-
B.createStore(loc.getValue(), ssaUpdater.GetValueInMiddleOfBlock(succ),
1072-
addr, StoreOwnershipQualifier::Unqualified);
1075+
auto *SI = B.createStore(loc.getValue(),
1076+
ssaUpdater.GetValueInMiddleOfBlock(succ),
1077+
addr, StoreOwnershipQualifier::Unqualified);
1078+
(void)SI;
1079+
LLVM_DEBUG(llvm::dbgs() << "Creating loop-exit store " << *SI);
10731080
}
10741081
}
10751082
}

0 commit comments

Comments
 (0)