Fix PR1495 and CodeGen/X86/2007-06-05-LSR-Dominator.ll
authorChris Lattner <sabre@nondot.org>
Wed, 6 Jun 2007 01:23:55 +0000 (01:23 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 6 Jun 2007 01:23:55 +0000 (01:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37454 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 449cee3bda243e545600be4d7b296f320c35c561..5c007551afb629e18b0f8d7fdba74eae0f4d6ad4 100644 (file)
@@ -560,11 +560,17 @@ Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
                                     OperandValToReplace->getType());
 
   Value *Base = Rewriter.expandCodeFor(NewBase, BaseInsertPt);
+
+  // If we are inserting the base and imm values in the same block, make sure to
+  // adjust the IP position if insertion reused a result.
+  if (IP == BaseInsertPt)
+    IP = Rewriter.getInsertionPoint();
   
   // Always emit the immediate (if non-zero) into the same block as the user.
   SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(Base), Imm);
   return Rewriter.expandCodeFor(NewValSCEV, IP,
                                 OperandValToReplace->getType());
+  
 }