diff options
author | Dan Gohman <gohman@apple.com> | 2007-07-31 17:22:27 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2007-07-31 17:22:27 +0000 |
commit | 8c4da37b1f516dba746206bac10770e0ecf6291b (patch) | |
tree | e51be56ccece6d9b77fc082c01056edeb398c73e /llvm | |
parent | cd1d086b5afdb7f5d93cc3e6824abfc9ba9e20b7 (diff) | |
download | bcm5719-llvm-8c4da37b1f516dba746206bac10770e0ecf6291b.tar.gz bcm5719-llvm-8c4da37b1f516dba746206bac10770e0ecf6291b.zip |
Use SCEVExpander::InsertCastOfTo instead of calling new IntToPtrInst
directly, because the insert point used by the SCEVExpander may vary
from what LSR originally computes.
llvm-svn: 40641
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 9689c120d69..64c60ba2e63 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -596,10 +596,13 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase, } } Value *NewVal = InsertCodeForBaseAtPosition(NewBase, Rewriter, InsertPt, L); - // Adjust the type back to match the Inst. + // Adjust the type back to match the Inst. Note that we can't use InsertPt + // here because the SCEVExpander may have inserted the instructions after + // that point, in its efforts to avoid inserting redundant expressions. if (isa<PointerType>(OperandValToReplace->getType())) { - NewVal = new IntToPtrInst(NewVal, OperandValToReplace->getType(), "cast", - InsertPt); + NewVal = SCEVExpander::InsertCastOfTo(Instruction::IntToPtr, + NewVal, + OperandValToReplace->getType()); } // Replace the use of the operand Value with the new Phi we just created. Inst->replaceUsesOfWith(OperandValToReplace, NewVal); @@ -648,9 +651,13 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase, Instruction *InsertPt = PN->getIncomingBlock(i)->getTerminator(); Code = InsertCodeForBaseAtPosition(NewBase, Rewriter, InsertPt, L); - // Adjust the type back to match the PHI. + // Adjust the type back to match the PHI. Note that we can't use InsertPt + // here because the SCEVExpander may have inserted its instructions after + // that point, in its efforts to avoid inserting redundant expressions. if (isa<PointerType>(PN->getType())) { - Code = new IntToPtrInst(Code, PN->getType(), "cast", InsertPt); + Code = SCEVExpander::InsertCastOfTo(Instruction::IntToPtr, + Code, + PN->getType()); } } |