[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Apr 7 11:17:00 PDT 2004
Changes in directory llvm/lib/Analysis:
ScalarEvolution.cpp updated: 1.6 -> 1.7
---
Log message:
Fix a bug Brian found.
---
Diffs of the changes: (+3 -2)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.6 llvm/lib/Analysis/ScalarEvolution.cpp:1.7
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.6 Mon Apr 5 14:05:15 2004
+++ llvm/lib/Analysis/ScalarEvolution.cpp Wed Apr 7 11:16:11 2004
@@ -924,6 +924,7 @@
// 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 @@
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 @@
}
}
- 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
More information about the llvm-commits
mailing list