[llvm-commits] [llvm] r40641 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Dan Gohman
djg at cray.com
Tue Jul 31 10:22:27 PDT 2007
Author: djg
Date: Tue Jul 31 12:22:27 2007
New Revision: 40641
URL: http://llvm.org/viewvc/llvm-project?rev=40641&view=rev
Log:
Use SCEVExpander::InsertCastOfTo instead of calling new IntToPtrInst
directly, because the insert point used by the SCEVExpander may vary
from what LSR originally computes.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=40641&r1=40640&r2=40641&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Jul 31 12:22:27 2007
@@ -596,10 +596,13 @@
}
}
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 @@
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());
}
}
More information about the llvm-commits
mailing list