Fix Transforms/LoopStrengthReduce/2005-08-17-OutOfLoopVariant.ll, a crash
authorChris Lattner <sabre@nondot.org>
Wed, 17 Aug 2005 21:22:41 +0000 (21:22 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Aug 2005 21:22:41 +0000 (21:22 +0000)
on 177.mesa

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

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index c8e86d8e9d5a6309771496531e4b952cd8f0658a..245a0266c197a9992a000d99e483f961f67b9c7c 100644 (file)
@@ -744,7 +744,10 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
     // value of the IV.  Do not put anything in the base, make sure it's all in
     // the immediate field to allow as much factoring as possible.
     if (!L->contains(UsersToProcess[i].Inst->getParent())) {
-      std::swap(UsersToProcess[i].Base, UsersToProcess[i].Imm);
+      UsersToProcess[i].Imm = SCEVAddExpr::get(UsersToProcess[i].Imm,
+                                               UsersToProcess[i].Base);
+      UsersToProcess[i].Base = 
+        SCEVUnknown::getIntegerSCEV(0, UsersToProcess[i].Base->getType());
     } else {
       
       // Addressing modes can be folded into loads and stores.  Be careful that