Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,6 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
// Therefore, the inferred address space must be the source space, according
// to our algorithm.
assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace);
if (Src->getType() != NewPtrType)
return new BitCastInst(Src, NewPtrType);
return Src;
}

Expand Down Expand Up @@ -739,7 +737,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
// If we had a no-op inttoptr/ptrtoint pair, we may still have inferred a
// source address space from a generic pointer source need to insert a cast
// back.
return CastInst::CreatePointerBitCastOrAddrSpaceCast(Src, NewPtrType);
return new AddrSpaceCastInst(Src, NewPtrType);
}
default:
llvm_unreachable("Unexpected opcode");
Expand All @@ -764,7 +762,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
// to our algorithm.
assert(CE->getOperand(0)->getType()->getPointerAddressSpace() ==
NewAddrSpace);
return ConstantExpr::getBitCast(CE->getOperand(0), TargetType);
return CE->getOperand(0);
}

if (CE->getOpcode() == Instruction::BitCast) {
Expand All @@ -777,7 +775,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
assert(isNoopPtrIntCastPair(cast<Operator>(CE), *DL, TTI));
Constant *Src = cast<ConstantExpr>(CE->getOperand(0))->getOperand(0);
assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace);
return ConstantExpr::getBitCast(Src, TargetType);
return Src;
}

// Computes the operands of the new constant expression.
Expand Down