mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 05:22:04 +00:00
LSR: Fold redundant bitcasts on-the-fly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146597 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -73,9 +73,14 @@ Value *SCEVExpander::InsertNoopCastOfTo(Value *V, Type *Ty) {
|
||||
"InsertNoopCastOfTo cannot change sizes!");
|
||||
|
||||
// Short-circuit unnecessary bitcasts.
|
||||
if (Op == Instruction::BitCast && V->getType() == Ty)
|
||||
return V;
|
||||
|
||||
if (Op == Instruction::BitCast) {
|
||||
if (V->getType() == Ty)
|
||||
return V;
|
||||
if (CastInst *CI = dyn_cast<CastInst>(V)) {
|
||||
if (CI->getOperand(0)->getType() == Ty)
|
||||
return CI->getOperand(0);
|
||||
}
|
||||
}
|
||||
// Short-circuit unnecessary inttoptr<->ptrtoint casts.
|
||||
if ((Op == Instruction::PtrToInt || Op == Instruction::IntToPtr) &&
|
||||
SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(V->getType())) {
|
||||
|
||||
Reference in New Issue
Block a user