diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-08 18:33:12 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-08 18:33:12 +0000 |
commit | 223a5d27632e23a09caa5eac8a5d380be044ee46 (patch) | |
tree | b16b64cc31322e7654aa59b2dfd9b1c3bc42e527 /llvm | |
parent | 4e2f3ace2c25455b96547b66966d9b0597bbcdb4 (diff) | |
download | bcm5719-llvm-223a5d27632e23a09caa5eac8a5d380be044ee46.tar.gz bcm5719-llvm-223a5d27632e23a09caa5eac8a5d380be044ee46.zip |
Canonicalize nested AddRecs in by nesting them in order of loop depth.
llvm-svn: 54545
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 84e02e47a0c..00a4475e28e 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -1158,6 +1158,19 @@ SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands, return getAddRecExpr(Operands, L); // { X,+,0 } --> X } + // Canonicalize nested AddRecs in by nesting them in order of loop depth. + if (SCEVAddRecExpr *NestedAR = dyn_cast<SCEVAddRecExpr>(Operands[0])) { + const Loop* NestedLoop = NestedAR->getLoop(); + if (L->getLoopDepth() < NestedLoop->getLoopDepth()) { + std::vector<SCEVHandle> NestedOperands(NestedAR->op_begin(), + NestedAR->op_end()); + SCEVHandle NestedARHandle(NestedAR); + Operands[0] = NestedAR->getStart(); + NestedOperands[0] = getAddRecExpr(Operands, L); + return getAddRecExpr(NestedOperands, NestedLoop); + } + } + SCEVAddRecExpr *&Result = (*SCEVAddRecExprs)[std::make_pair(L, std::vector<SCEV*>(Operands.begin(), Operands.end()))]; |