@@ -660,8 +660,6 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
660
660
// Therefore, the inferred address space must be the source space, according
661
661
// to our algorithm.
662
662
assert (Src->getType ()->getPointerAddressSpace () == NewAddrSpace);
663
- if (Src->getType () != NewPtrType)
664
- return new BitCastInst (Src, NewPtrType);
665
663
return Src;
666
664
}
667
665
@@ -739,7 +737,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
739
737
// If we had a no-op inttoptr/ptrtoint pair, we may still have inferred a
740
738
// source address space from a generic pointer source need to insert a cast
741
739
// back.
742
- return CastInst::CreatePointerBitCastOrAddrSpaceCast (Src, NewPtrType);
740
+ return new AddrSpaceCastInst (Src, NewPtrType);
743
741
}
744
742
default :
745
743
llvm_unreachable (" Unexpected opcode" );
@@ -764,7 +762,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
764
762
// to our algorithm.
765
763
assert (CE->getOperand (0 )->getType ()->getPointerAddressSpace () ==
766
764
NewAddrSpace);
767
- return ConstantExpr::getBitCast ( CE->getOperand (0 ), TargetType );
765
+ return CE->getOperand (0 );
768
766
}
769
767
770
768
if (CE->getOpcode () == Instruction::BitCast) {
@@ -777,7 +775,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
777
775
assert (isNoopPtrIntCastPair (cast<Operator>(CE), *DL, TTI));
778
776
Constant *Src = cast<ConstantExpr>(CE->getOperand (0 ))->getOperand (0 );
779
777
assert (Src->getType ()->getPointerAddressSpace () == NewAddrSpace);
780
- return ConstantExpr::getBitCast ( Src, TargetType) ;
778
+ return Src;
781
779
}
782
780
783
781
// Computes the operands of the new constant expression.
0 commit comments