aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-27 18:39:08 +0000
committerChris Lattner <sabre@nondot.org>2010-12-27 18:39:08 +0000
commit2e12f1ac6ebd49e5c41b7e9dcd802f3df40a1bc7 (patch)
tree32b0115eb1fe433d966f6cd26b79415bce3d62a4 /lib/Transforms/Scalar/LoopIdiomRecognize.cpp
parentbdc3167c086dd4358e24692075db5e7784140843 (diff)
fix some issues Frits noticed, add AliasAnalysis as a dependency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIdiomRecognize.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIdiomRecognize.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index f8748efece..476cb284ba 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -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 @@ namespace {
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(LoopInfo)
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 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
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 @@ processLoopStoreOfSplatValue(StoreInst *SI, unsigned StoreSize,
// 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.