mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Teach SCEVExpander::InsertCastOfTo to avoid creating inttoptr-of-ptrtoint
and ptrtoint-of-inttoptr expressions. This fixes a regression in 300.twolf. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69293 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user