aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-07 16:16:11 +0000
committerChris Lattner <sabre@nondot.org>2004-04-07 16:16:11 +0000
commit627018b4b3ff566eb6eba487c93e76d9ae1f46ea (patch)
treeb240fd8fe84d6e325134e7bda03f63414c023e12 /lib/Analysis/ScalarEvolution.cpp
parent2d26135b90305721e2ddbb854881682fe460f44e (diff)
downloadexternal_llvm-627018b4b3ff566eb6eba487c93e76d9ae1f46ea.zip
external_llvm-627018b4b3ff566eb6eba487c93e76d9ae1f46ea.tar.gz
external_llvm-627018b4b3ff566eb6eba487c93e76d9ae1f46ea.tar.bz2
Fix a bug Brian found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 77f4b1c..70a7d04 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/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