diff options
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index d91061b2b3..0033fb4ae4 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -26,6 +26,14 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V, if (opcode == Instruction::BitCast && V->getType() == Ty) return V; + // Short-circuit unnecessary inttoptr<->ptrtoint casts. + if (opcode == Instruction::PtrToInt && Ty == TD.getIntPtrType()) + if (IntToPtrInst *ITP = dyn_cast<IntToPtrInst>(V)) + return ITP->getOperand(0); + if (opcode == Instruction::IntToPtr && V->getType() == TD.getIntPtrType()) + if (PtrToIntInst *PTI = dyn_cast<PtrToIntInst>(V)) + return PTI->getOperand(0); + // FIXME: keep track of the cast instruction. if (Constant *C = dyn_cast<Constant>(V)) return ConstantExpr::getCast(opcode, C, Ty); |