[PATCH] D55313: [LICM] *Actually* disable ControlFlowHoisting.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 5 02:17:43 PST 2018
asbirlea created this revision.
asbirlea added reviewers: john.brawn, mkazantsev.
Herald added subscribers: jlebar, sanjoy.
The remaining code paths that ControlFlowHoisting introduced that were
not disabled, increased compile time by 3x for some benchmarks.
The time is spent in DominatorTree updates.
Repository:
rL LLVM
https://reviews.llvm.org/D55313
Files:
lib/Transforms/Scalar/LICM.cpp
Index: lib/Transforms/Scalar/LICM.cpp
===================================================================
--- lib/Transforms/Scalar/LICM.cpp
+++ lib/Transforms/Scalar/LICM.cpp
@@ -566,6 +566,8 @@
}
BasicBlock *getOrCreateHoistedBlock(BasicBlock *BB) {
+ if (!ControlFlowHoisting)
+ return CurLoop->getLoopPreheader();
// If BB has already been hoisted, return that
if (HoistDestinationMap.count(BB))
return HoistDestinationMap[BB];
@@ -801,21 +803,24 @@
// and also keep track of where in the block we are rehoisting to to make sure
// that we rehoist instructions before the instructions that use them.
Instruction *HoistPoint = nullptr;
- for (Instruction *I : reverse(HoistedInstructions)) {
- if (!llvm::all_of(I->uses(), [&](Use &U) { return DT->dominates(I, U); })) {
- BasicBlock *Dominator =
- DT->getNode(I->getParent())->getIDom()->getBlock();
- LLVM_DEBUG(dbgs() << "LICM rehoisting to " << Dominator->getName() << ": "
- << *I << "\n");
- if (!HoistPoint || HoistPoint->getParent() != Dominator) {
- if (HoistPoint)
- assert(DT->dominates(Dominator, HoistPoint->getParent()) &&
- "New hoist point expected to dominate old hoist point");
- HoistPoint = Dominator->getTerminator();
+ if (ControlFlowHoisting) {
+ for (Instruction *I : reverse(HoistedInstructions)) {
+ if (!llvm::all_of(I->uses(),
+ [&](Use &U) { return DT->dominates(I, U); })) {
+ BasicBlock *Dominator =
+ DT->getNode(I->getParent())->getIDom()->getBlock();
+ LLVM_DEBUG(dbgs() << "LICM rehoisting to " << Dominator->getName()
+ << ": " << *I << "\n");
+ if (!HoistPoint || HoistPoint->getParent() != Dominator) {
+ if (HoistPoint)
+ assert(DT->dominates(Dominator, HoistPoint->getParent()) &&
+ "New hoist point expected to dominate old hoist point");
+ HoistPoint = Dominator->getTerminator();
+ }
+ moveInstructionBefore(*I, *HoistPoint, *SafetyInfo);
+ HoistPoint = I;
+ Changed = true;
}
- moveInstructionBefore(*I, *HoistPoint, *SafetyInfo);
- HoistPoint = I;
- Changed = true;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55313.176777.patch
Type: text/x-patch
Size: 2296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/fbe8e8d6/attachment.bin>
More information about the llvm-commits
mailing list