1 + 100 + 51 == 152, not 52.
authorChris Lattner <sabre@nondot.org>
Sat, 26 Feb 2005 18:50:19 +0000 (18:50 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 26 Feb 2005 18:50:19 +0000 (18:50 +0000)
If we fold three constants together (c1+c2+c3), make sure to keep
LHSC updated, instead of reusing (in this case), the 1 instead of the
partial sum.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20337 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index a47bf0d34855e13ac72f61b3f4c1d36adcf2f53b..d2331ba33867fd2e44e7799ce4d6511cb34f5fe8 100644 (file)
@@ -625,6 +625,7 @@ SCEVHandle SCEVAddExpr::get(std::vector<SCEVHandle> &Ops) {
         Ops[0] = SCEVConstant::get(CI);
         Ops.erase(Ops.begin()+1);  // Erase the folded element
         if (Ops.size() == 1) return Ops[0];
+        LHSC = cast<SCEVConstant>(Ops[0]);
       } else {
         // If we couldn't fold the expression, move to the next constant.  Note
         // that this is impossible to happen in practice because we always
@@ -861,6 +862,7 @@ SCEVHandle SCEVMulExpr::get(std::vector<SCEVHandle> &Ops) {
         Ops[0] = SCEVConstant::get(CI);
         Ops.erase(Ops.begin()+1);  // Erase the folded element
         if (Ops.size() == 1) return Ops[0];
+        LHSC = cast<SCEVConstant>(Ops[0]);
       } else {
         // If we couldn't fold the expression, move to the next constant.  Note
         // that this is impossible to happen in practice because we always