diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2005-02-27 21:08:04 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2005-02-27 21:08:04 +0000 |
commit | 5e1e5e13ffeb4f1f61858f1073c31ad5e9d967b1 (patch) | |
tree | fedf3cc51a935de4b037d60bde950aa5ae18361d /lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | f465db6c6a5a877aa791abfc3837d62c491dacd5 (diff) |
PHI nodes were incorrectly placed when more than one GEP is reduced in a loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 898c7f41b5..19381b9e8e 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -99,7 +99,8 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, // GEP. // // We currently only handle GEP instructions that consist of zero or more - // constants and one instance of the canonical induction variable. + // constants or loop invariable expressions prior to an instance of the + // canonical induction variable. unsigned indvar = 0; std::vector<Value *> pre_op_vector; std::vector<Value *> inc_op_vector; @@ -208,21 +209,19 @@ void LoopStrengthReduce::runOnLoop(Loop *L) { if (0 == PN) return; - // Insert secondary PHI nodes after the canonical induction variable's PHI - // for the strength reduced pointers that we will be creating. - Instruction *InsertBefore = PN->getNext(); - // FIXME: Need to use SCEV to detect GEP uses of the indvar, since indvars // pass creates code like this, which we can't currently detect: // %tmp.1 = sub uint 2000, %indvar // %tmp.8 = getelementptr int* %y, uint %tmp.1 - // Strength reduce all GEPs in the Loop + // Strength reduce all GEPs in the Loop. Insert secondary PHI nodes for the + // strength reduced pointers we'll be creating after the canonical induction + // variable's PHI. std::set<Instruction*> DeadInsts; for (Value::use_iterator UI = PN->use_begin(), UE = PN->use_end(); UI != UE; ++UI) if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(*UI)) - strengthReduceGEP(GEPI, L, InsertBefore, DeadInsts); + strengthReduceGEP(GEPI, L, PN->getNext(), DeadInsts); // Clean up after ourselves if (!DeadInsts.empty()) { |