[llvm-commits] [llvm] r123066 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 8 09:38:45 PST 2011
Author: lattner
Date: Sat Jan 8 11:38:45 2011
New Revision: 123066
URL: http://llvm.org/viewvc/llvm-project?rev=123066&view=rev
Log:
fix an issue duncan pointed out, which could cause loop rotate
to violate LCSSA form
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=123066&r1=123065&r2=123066&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Sat Jan 8 11:38:45 2011
@@ -70,6 +70,7 @@
void preserveCanonicalLoopForm(LPPassManager &LPM);
private:
+ LoopInfo *LI;
Loop *L;
BasicBlock *OrigHeader;
BasicBlock *OrigPreHeader;
@@ -89,21 +90,31 @@
Pass *llvm::createLoopRotatePass() { return new LoopRotate(); }
+/// Initialize local data
+void LoopRotate::initialize() {
+ L = NULL;
+ OrigHeader = NULL;
+ OrigPreHeader = NULL;
+ NewHeader = NULL;
+ Exit = NULL;
+}
+
/// Rotate Loop L as many times as possible. Return true if
/// the loop is rotated at least once.
bool LoopRotate::runOnLoop(Loop *Lp, LPPassManager &LPM) {
+ LI = &getAnalysis<LoopInfo>();
- bool RotatedOneLoop = false;
initialize();
LPM_Ptr = &LPM;
// One loop can be rotated multiple times.
+ bool MadeChange = false;
while (rotateLoop(Lp,LPM)) {
- RotatedOneLoop = true;
+ MadeChange = true;
initialize();
}
- return RotatedOneLoop;
+ return MadeChange;
}
/// Rotate loop LP. Return true if the loop is rotated.
@@ -213,7 +224,8 @@
// With the operands remapped, see if the instruction constant folds or is
// otherwise simplifyable. This commonly occurs because the entry from PHI
// nodes allows icmps and other instructions to fold.
- if (Value *V = SimplifyInstruction(C)) {
+ Value *V = SimplifyInstruction(C);
+ if (V && LI->replacementPreservesLCSSAForm(C, V)) {
// If so, then delete the temporary instruction and stick the folded value
// in the map.
delete C;
@@ -322,14 +334,6 @@
return true;
}
-/// Initialize local data
-void LoopRotate::initialize() {
- L = NULL;
- OrigHeader = NULL;
- OrigPreHeader = NULL;
- NewHeader = NULL;
- Exit = NULL;
-}
/// After loop rotation, loop pre-header has multiple sucessors.
/// Insert one forwarding basic block to ensure that loop pre-header
More information about the llvm-commits
mailing list