summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-16 15:52:57 +0000
committerDan Gohman <gohman@apple.com>2009-04-16 15:52:57 +0000
commit66e038a3e3e347d039383f24955bb1ce5217f110 (patch)
tree6cbdcbe3eef02d374f0eb31dec903070c4548d81 /llvm/lib
parent8798bd1bf9fbfe7bd1ad2e1a93351b3e2f7a9c19 (diff)
downloadbcm5719-llvm-66e038a3e3e347d039383f24955bb1ce5217f110.tar.gz
bcm5719-llvm-66e038a3e3e347d039383f24955bb1ce5217f110.zip
Teach SCEVExpander::InsertCastOfTo to avoid creating inttoptr-of-ptrtoint
and ptrtoint-of-inttoptr expressions. This fixes a regression in 300.twolf. llvm-svn: 69293
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index d91061b2b3a..0033fb4ae4a 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud