[PATCH] Teaching loop simplify to preserve LCSSA
Dinesh Dwivedi
dinesh.d at samsung.com
Wed May 7 07:08:29 PDT 2014
Added parameter to SimplifyLoop to selectively KeepSingleValuePHIs. I am looking in to making LoopSimplify pass preserve LCSSA
http://reviews.llvm.org/D2986
Files:
include/llvm/Transforms/Utils/LoopUtils.h
lib/Transforms/Utils/LoopSimplify.cpp
lib/Transforms/Utils/LoopUnroll.cpp
Index: include/llvm/Transforms/Utils/LoopUtils.h
===================================================================
--- include/llvm/Transforms/Utils/LoopUtils.h
+++ include/llvm/Transforms/Utils/LoopUtils.h
@@ -32,7 +32,8 @@
/// will optionally update \c AliasAnalysis and \c ScalarEvolution analyses if
/// passed into it.
bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Pass *PP,
- AliasAnalysis *AA = nullptr, ScalarEvolution *SE = nullptr);
+ AliasAnalysis *AA = nullptr, ScalarEvolution *SE = nullptr,
+ bool KeepSingleValuePHIs = false);
/// \brief Put loop into LCSSA form.
///
Index: lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- lib/Transforms/Utils/LoopSimplify.cpp
+++ lib/Transforms/Utils/LoopSimplify.cpp
@@ -473,7 +473,8 @@
/// explicit if they accepted the analysis directly and then updated it.
static bool simplifyOneLoop(Loop *L, SmallVectorImpl<Loop *> &Worklist,
AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI,
- ScalarEvolution *SE, Pass *PP) {
+ ScalarEvolution *SE, Pass *PP,
+ bool KeepSingleValuePHIs = false) {
bool Changed = false;
ReprocessLoop:
@@ -699,17 +700,18 @@
}
DT->eraseNode(ExitingBlock);
- BI->getSuccessor(0)->removePredecessor(ExitingBlock);
- BI->getSuccessor(1)->removePredecessor(ExitingBlock);
+ BI->getSuccessor(0)->removePredecessor(ExitingBlock, KeepSingleValuePHIs);
+ BI->getSuccessor(1)->removePredecessor(ExitingBlock, KeepSingleValuePHIs);
ExitingBlock->eraseFromParent();
}
}
return Changed;
}
bool llvm::simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Pass *PP,
- AliasAnalysis *AA, ScalarEvolution *SE) {
+ AliasAnalysis *AA, ScalarEvolution *SE,
+ bool KeepSingleValuePHIs) {
bool Changed = false;
// Worklist maintains our depth-first queue of loops in this nest to process.
@@ -726,7 +728,8 @@
}
while (!Worklist.empty())
- Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, AA, DT, LI, SE, PP);
+ Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, AA, DT, LI,
+ SE, PP, KeepSingleValuePHIs);
return Changed;
}
Index: lib/Transforms/Utils/LoopUnroll.cpp
===================================================================
--- lib/Transforms/Utils/LoopUnroll.cpp
+++ lib/Transforms/Utils/LoopUnroll.cpp
@@ -484,9 +484,9 @@
if (!OuterL && !CompletelyUnroll)
OuterL = L;
if (OuterL) {
- ScalarEvolution *SE = PP->getAnalysisIfAvailable<ScalarEvolution>();
- simplifyLoop(OuterL, DT, LI, PP, /*AliasAnalysis*/ nullptr, SE);
- formLCSSARecursively(*OuterL, *DT, SE);
+ simplifyLoop(OuterL, DT, LI, PP, /*AliasAnalysis*/ 0,
+ PP->getAnalysisIfAvailable<ScalarEvolution>(),
+ /* KeepSingleValuePHIs = */ true);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2986.9169.patch
Type: text/x-patch
Size: 3124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140507/6bf684ce/attachment.bin>
More information about the llvm-commits
mailing list