diff options
author | Andrew Trick <atrick@apple.com> | 2011-03-14 17:38:54 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2011-03-14 17:38:54 +0000 |
commit | e92dcceab733b8518e9489d74f4e3741f2f77257 (patch) | |
tree | 6b5c81a0e9c39fafa5fd2bc817de6fba22052e6f /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 876ee079fc85458af424a815ba9e0ea18fe0635c (diff) | |
download | bcm5719-llvm-e92dcceab733b8518e9489d74f4e3741f2f77257.tar.gz bcm5719-llvm-e92dcceab733b8518e9489d74f4e3741f2f77257.zip |
Negating a recurrence preserves no-self-wrap.
llvm-svn: 127593
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index a64a7c18330..ce4a724c0fc 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -1792,6 +1792,17 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, if (AnyFolded) return getAddExpr(NewOps); } + else if (const SCEVAddRecExpr * + AddRec = dyn_cast<SCEVAddRecExpr>(Ops[1])) { + // Negation preserves a recurrence's no self-wrap property. + SmallVector<const SCEV *, 4> Operands; + for (SCEVAddRecExpr::op_iterator I = AddRec->op_begin(), + E = AddRec->op_end(); I != E; ++I) { + Operands.push_back(getMulExpr(Ops[0], *I)); + } + return getAddRecExpr(Operands, AddRec->getLoop(), + AddRec->getNoWrapFlags(SCEV::FlagNW)); + } } } |