summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-02-01 13:35:14 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-02-01 13:35:14 +0000
commit115fd30b245065324193baefe418cd7e6b429488 (patch)
treea0c11e583cac3f2a25dbee5d1a94167ebccc1520 /lib
parenta7bc25e34cf980e283bb0485d8882d4cd1bb377a (diff)
downloadllvm-115fd30b245065324193baefe418cd7e6b429488.tar.gz
llvm-115fd30b245065324193baefe418cd7e6b429488.tar.bz2
llvm-115fd30b245065324193baefe418cd7e6b429488.tar.xz
[LPM] Apply a really big hammer to fix PR18688 by recursively reforming
LCSSA when we promote to SSA registers inside of LICM. Currently, this is actually necessary. The promotion logic in LICM uses SSAUpdater which doesn't understand how to place LCSSA PHI nodes. Teaching it to do so would be a very significant undertaking. It may be worthwhile and I've left a FIXME about this in the code as well as starting a thread on llvmdev to try to figure out the right long-term solution. For now, the PR needs to be fixed. Short of using the promition SSAUpdater to place both the LCSSA PHI nodes and the promoted PHI nodes, I don't see a cleaner or cheaper way of achieving this. Fortunately, LCSSA is relatively lazy and sparse -- it should only update instructions which need it. We can also skip the recursive variant when we don't promote to SSA values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/LICM.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index e62daa63cd..1ce0cbc1c4 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -286,15 +286,28 @@ bool LICM::runOnLoop(Loop *L, LPPassManager &LPM) {
for (AliasSetTracker::iterator I = CurAST->begin(), E = CurAST->end();
I != E; ++I)
PromoteAliasSet(*I, ExitBlocks, InsertPts);
- }
- // If we have successfully changed the loop, re-form LCSSA and also re-form
- // LCSSA in the parent loop as hoisting or sinking may have broken it.
- if (Changed) {
+ // Once we have promoted values across the loop body we have to recursively
+ // reform LCSSA as any nested loop may now have values defined within the
+ // loop used in the outer loop.
+ // FIXME: This is really heavy handed. It would be a bit better to use an
+ // SSAUpdater strategy during promotion that was LCSSA aware and reformed
+ // it as it went.
+ if (Changed)
+ formLCSSARecursively(*L, *DT, getAnalysisIfAvailable<ScalarEvolution>());
+
+ } else if (Changed) {
+ // If we have successfully changed the loop but not used SSAUpdater to
+ // re-write instructions throughout the loop body, re-form LCSSA just for
+ // this loop.
formLCSSA(*L, *DT, getAnalysisIfAvailable<ScalarEvolution>());
+ }
+
+ // Regardless of how we changed the loop, reform LCSSA on its parent as
+ // hoisting or sinking could have disrupted it.
+ if (Changed)
if (Loop *ParentL = L->getParentLoop())
formLCSSA(*ParentL, *DT, getAnalysisIfAvailable<ScalarEvolution>());
- }
// Clear out loops state information for the next iteration
CurLoop = 0;