diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-01 17:00:00 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-01 17:00:00 +0000 |
| commit | 150b4c3890ca1d756a93152aff7b51f0e57c3e3e (patch) | |
| tree | 37c7f14a466479a0f2728e81dbbd0aa4f6758cdd /llvm/lib | |
| parent | 719f7d5c864065c4402619ebb71191d9b71dee5f (diff) | |
| download | bcm5719-llvm-150b4c3890ca1d756a93152aff7b51f0e57c3e3e.tar.gz bcm5719-llvm-150b4c3890ca1d756a93152aff7b51f0e57c3e3e.zip | |
Short-circuit inttoptr-ptrtoint constant expressions; these aren't
always folded by the regular constant folder because it doesn't have
TargetData information.
llvm-svn: 70553
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 9676ea20af5..be91c0d7249 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -27,13 +27,20 @@ Value *SCEVExpander::InsertCastOfTo(Instruction::CastOps opcode, Value *V, // Short-circuit unnecessary inttoptr<->ptrtoint casts. if ((opcode == Instruction::PtrToInt || opcode == Instruction::IntToPtr) && - SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(V->getType())) + SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(V->getType())) { if (CastInst *CI = dyn_cast<CastInst>(V)) if ((CI->getOpcode() == Instruction::PtrToInt || CI->getOpcode() == Instruction::IntToPtr) && SE.getTypeSizeInBits(CI->getType()) == SE.getTypeSizeInBits(CI->getOperand(0)->getType())) return CI->getOperand(0); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) + if ((CE->getOpcode() == Instruction::PtrToInt || + CE->getOpcode() == Instruction::IntToPtr) && + SE.getTypeSizeInBits(CE->getType()) == + SE.getTypeSizeInBits(CE->getOperand(0)->getType())) + return CE->getOperand(0); + } // FIXME: keep track of the cast instruction. if (Constant *C = dyn_cast<Constant>(V)) |

