From: Chris Lattner Date: Wed, 6 Jun 2007 01:23:55 +0000 (+0000) Subject: Fix PR1495 and CodeGen/X86/2007-06-05-LSR-Dominator.ll X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b47f6124f4893c00573d1a5be56a6e4cf877faeb;p=oota-llvm.git Fix PR1495 and CodeGen/X86/2007-06-05-LSR-Dominator.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37454 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 449cee3bda2..5c007551afb 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -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()); + }