summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-11-06 04:17:40 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-11-06 04:17:40 +0000
commit0042c06e8bebd2cbed8ee1fae1bc57eaddb472f3 (patch)
treea6821c65cde27f41b05e42b3cb9bba48d858f4e1 /llvm/lib
parent96d12513a19ef62704c6a04d275845b4f806ad8f (diff)
downloadbcm5719-llvm-0042c06e8bebd2cbed8ee1fae1bc57eaddb472f3.tar.gz
bcm5719-llvm-0042c06e8bebd2cbed8ee1fae1bc57eaddb472f3.zip
[LICM] Remove too conservative IsMustExecute variable
LICM relies on variable `MustExecute` which is conservatively set to `false` in all non-headers. It is used when we decide whether or not we want to hoist an instruction or a guard. For the guards, it might be too conservative to use this variable, we can instead use a more precise logic from LoopSafetyInfo. Currently it is only NFC because `IsMemoryNotModified` is also conservatively set to `false` for all non-headers, and we cannot hoist guards from non-header blocks. However once we give up using `IsMemoryNotModified` and use a smarter check instead, this will allow us to hoist guards from all mustexecute non-header blocks. Differential Revision: https://reviews.llvm.org/D50888 Reveiwed By: fedor.sergeev llvm-svn: 346204
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index d6dfdc7efed..7789cb92345 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -460,14 +460,10 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
if (inSubLoop(BB, CurLoop, LI))
continue;
- // Keep track of whether the prefix of instructions visited so far are such
- // that the next instruction visited is guaranteed to execute if the loop
- // is entered.
- bool IsMustExecute = CurLoop->getHeader() == BB;
// Keep track of whether the prefix instructions could have written memory.
- // TODO: This and IsMustExecute may be done smarter if we keep track of all
- // throwing and mem-writing operations in every block, e.g. using something
- // similar to isGuaranteedToExecute.
+ // TODO: This may be done smarter if we keep track of all throwing and
+ // mem-writing operations in every block, e.g. using something similar to
+ // isGuaranteedToExecute.
bool IsMemoryNotModified = CurLoop->getHeader() == BB;
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;) {
@@ -493,10 +489,9 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
//
if (CurLoop->hasLoopInvariantOperands(&I) &&
canSinkOrHoistInst(I, AA, DT, CurLoop, CurAST, true, ORE) &&
- (IsMustExecute ||
- isSafeToExecuteUnconditionally(
- I, DT, CurLoop, SafetyInfo, ORE,
- CurLoop->getLoopPreheader()->getTerminator()))) {
+ isSafeToExecuteUnconditionally(
+ I, DT, CurLoop, SafetyInfo, ORE,
+ CurLoop->getLoopPreheader()->getTerminator())) {
hoist(I, DT, CurLoop, SafetyInfo, ORE);
Changed = true;
continue;
@@ -531,15 +526,13 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
if (((I.use_empty() &&
match(&I, m_Intrinsic<Intrinsic::invariant_start>())) ||
isGuard(&I)) &&
- IsMustExecute && IsMemoryNotModified &&
- CurLoop->hasLoopInvariantOperands(&I)) {
+ IsMemoryNotModified && CurLoop->hasLoopInvariantOperands(&I) &&
+ SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop)) {
hoist(I, DT, CurLoop, SafetyInfo, ORE);
Changed = true;
continue;
}
- if (IsMustExecute)
- IsMustExecute = isGuaranteedToTransferExecutionToSuccessor(&I);
if (IsMemoryNotModified)
IsMemoryNotModified = !I.mayWriteToMemory();
}
OpenPOWER on IntegriCloud