Skip to content

Commit 3916ecb

Browse files
arsenmJaddyen
authored andcommitted
InferAddressSpaces: Stop trying to insert pointer bitcasts (llvm#140873)
1 parent 743f920 commit 3916ecb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,6 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
660660
// Therefore, the inferred address space must be the source space, according
661661
// to our algorithm.
662662
assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace);
663-
if (Src->getType() != NewPtrType)
664-
return new BitCastInst(Src, NewPtrType);
665663
return Src;
666664
}
667665

@@ -739,7 +737,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
739737
// If we had a no-op inttoptr/ptrtoint pair, we may still have inferred a
740738
// source address space from a generic pointer source need to insert a cast
741739
// back.
742-
return CastInst::CreatePointerBitCastOrAddrSpaceCast(Src, NewPtrType);
740+
return new AddrSpaceCastInst(Src, NewPtrType);
743741
}
744742
default:
745743
llvm_unreachable("Unexpected opcode");
@@ -764,7 +762,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
764762
// to our algorithm.
765763
assert(CE->getOperand(0)->getType()->getPointerAddressSpace() ==
766764
NewAddrSpace);
767-
return ConstantExpr::getBitCast(CE->getOperand(0), TargetType);
765+
return CE->getOperand(0);
768766
}
769767

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

783781
// Computes the operands of the new constant expression.

0 commit comments

Comments
 (0)