[llvm-commits] [llvm] r122585 - /llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
Chris Lattner
sabre at nondot.org
Mon Dec 27 10:39:08 PST 2010
Author: lattner
Date: Mon Dec 27 12:39:08 2010
New Revision: 122585
URL: http://llvm.org/viewvc/llvm-project?rev=122585&view=rev
Log:
fix some issues Frits noticed, add AliasAnalysis as a dependency
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=122585&r1=122584&r2=122585&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Mon Dec 27 12:39:08 2010
@@ -15,6 +15,7 @@
#define DEBUG_TYPE "loop-idiom"
#include "llvm/Transforms/Scalar.h"
+#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
@@ -59,6 +60,8 @@
AU.addPreservedID(LoopSimplifyID);
AU.addRequiredID(LCSSAID);
AU.addPreservedID(LCSSAID);
+ AU.addRequired<AliasAnalysis>();
+ AU.addPreserved<AliasAnalysis>();
AU.addRequired<ScalarEvolution>();
AU.addPreserved<ScalarEvolution>();
AU.addPreserved<DominatorTree>();
@@ -73,6 +76,7 @@
INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
INITIALIZE_PASS_DEPENDENCY(LCSSA)
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
+INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
INITIALIZE_PASS_END(LoopIdiomRecognize, "loop-idiom", "Recognize loop idioms",
false, false)
@@ -141,13 +145,15 @@
StoreInst *SI = dyn_cast<StoreInst>(I++);
if (SI == 0 || SI->isVolatile()) continue;
- WeakVH InstPtr;
- if (processLoopStore(SI, BECount)) {
- // If processing the store invalidated our iterator, start over from the
- // head of the loop.
- if (InstPtr == 0)
- I = BB->begin();
- }
+ WeakVH InstPtr(SI);
+ if (!processLoopStore(SI, BECount)) continue;
+
+ MadeChange = true;
+
+ // If processing the store invalidated our iterator, start over from the
+ // head of the loop.
+ if (InstPtr == 0)
+ I = BB->begin();
}
return MadeChange;
@@ -204,6 +210,10 @@
// would be unsafe to do if there is anything else in the loop that may read
// or write to the aliased location. Check for an alias.
+ // FIXME: Need to get a base pointer that is valid.
+ // if (LoopCanModRefLocation(SI->getPointerOperand())
+
+
// FIXME: TODO safety check.
// Okay, everything looks good, insert the memset.
More information about the llvm-commits
mailing list