mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-10 05:41:40 +00:00
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
This commit is contained in:
parent
ac4de6a92e
commit
bc336eab6e
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user