diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-07 16:16:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-07 16:16:11 +0000 |
commit | 74498e1066c3e22c34e3b26c8a62948c5341e3f6 (patch) | |
tree | 9c4e307672741f1fd015b3f7dc1ee34501586341 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 52ad5f94e20095d0799fdd2d3f937bf7583e0531 (diff) | |
download | bcm5719-llvm-74498e1066c3e22c34e3b26c8a62948c5341e3f6.tar.gz bcm5719-llvm-74498e1066c3e22c34e3b26c8a62948c5341e3f6.zip |
Fix a bug Brian found.
llvm-svn: 12754
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 77f4b1c6066..70a7d04121c 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -924,6 +924,7 @@ SCEVHandle SCEVZeroExtendExpr::get(const SCEVHandle &Op, const Type *Ty) { // get - Get a canonical add expression, or something simpler if possible. SCEVHandle SCEVAddExpr::get(std::vector<SCEVHandle> &Ops) { assert(!Ops.empty() && "Cannot get empty add!"); + if (Ops.size() == 1) return Ops[0]; // Sort by complexity, this groups all similar expression types together. std::sort(Ops.begin(), Ops.end(), SCEVComplexityCompare()); @@ -932,6 +933,7 @@ SCEVHandle SCEVAddExpr::get(std::vector<SCEVHandle> &Ops) { unsigned Idx = 0; if (SCEVConstant *LHSC = dyn_cast<SCEVConstant>(Ops[0])) { ++Idx; + assert(Idx < Ops.size()); while (SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) { // We found two constants, fold them together! Constant *Fold = ConstantExpr::getAdd(LHSC->getValue(), RHSC->getValue()); @@ -954,8 +956,7 @@ SCEVHandle SCEVAddExpr::get(std::vector<SCEVHandle> &Ops) { } } - if (Ops.size() == 1) - return Ops[0]; + if (Ops.size() == 1) return Ops[0]; // Okay, check to see if the same value occurs in the operand list twice. If // so, merge them together into an multiply expression. Since we sorted the |