diff options
| author | John Brawn <john.brawn@arm.com> | 2019-01-04 17:12:09 +0000 |
|---|---|---|
| committer | John Brawn <john.brawn@arm.com> | 2019-01-04 17:12:09 +0000 |
| commit | 39ac159c24b5c0ae37506d1588321bebf429c973 (patch) | |
| tree | 8988081ca6579f7eb5993fb8b5f2c8d52ec00cc6 /llvm/lib/Transforms/Scalar | |
| parent | 2b506d9fe92bebe34f4954e737d63fcad0f46794 (diff) | |
| download | bcm5719-llvm-39ac159c24b5c0ae37506d1588321bebf429c973.tar.gz bcm5719-llvm-39ac159c24b5c0ae37506d1588321bebf429c973.zip | |
[LICM] Adjust how moving the re-hoist point works
In some cases the order that we hoist instructions in means that when rehoisting
(which uses the same order as hoisting) we can rehoist to a block A, then a
block B, then block A again. This currently causes an assertion failure as it
expects that when changing the hoist point it only ever moves to a block that
dominates the hoist point being moved from.
Fix this by moving the re-hoist point when it doesn't dominate the dominator of
hoisted instruction, or in other words when it wouldn't dominate the uses of
the instruction being rehoisted.
Differential Revision: https://reviews.llvm.org/D55266
llvm-svn: 350408
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 695eaf6cf4a..5ebf035bf51 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -809,14 +809,15 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI, [&](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 || !DT->dominates(HoistPoint->getParent(), Dominator)) { if (HoistPoint) assert(DT->dominates(Dominator, HoistPoint->getParent()) && "New hoist point expected to dominate old hoist point"); HoistPoint = Dominator->getTerminator(); } + LLVM_DEBUG(dbgs() << "LICM rehoisting to " + << HoistPoint->getParent()->getName() + << ": " << *I << "\n"); moveInstructionBefore(*I, *HoistPoint, *SafetyInfo); HoistPoint = I; Changed = true; |

