@@ -1927,11 +1927,8 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
1927
1927
unsigned AS = CI.getAddressSpace ();
1928
1928
if (CI.getOperand (0 )->getType ()->getScalarSizeInBits () !=
1929
1929
DL.getPointerSizeInBits (AS)) {
1930
- Type *Ty = DL.getIntPtrType (CI.getContext (), AS);
1931
- // Handle vectors of pointers.
1932
- if (auto *CIVTy = dyn_cast<VectorType>(CI.getType ()))
1933
- Ty = VectorType::get (Ty, CIVTy->getElementCount ());
1934
-
1930
+ Type *Ty = CI.getOperand (0 )->getType ()->getWithNewType (
1931
+ DL.getIntPtrType (CI.getContext (), AS));
1935
1932
Value *P = Builder.CreateZExtOrTrunc (CI.getOperand (0 ), Ty);
1936
1933
return new IntToPtrInst (P, CI.getType ());
1937
1934
}
@@ -1970,16 +1967,14 @@ Instruction *InstCombinerImpl::visitPtrToInt(PtrToIntInst &CI) {
1970
1967
// do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
1971
1968
// to be exposed to other transforms.
1972
1969
Value *SrcOp = CI.getPointerOperand ();
1970
+ Type *SrcTy = SrcOp->getType ();
1973
1971
Type *Ty = CI.getType ();
1974
1972
unsigned AS = CI.getPointerAddressSpace ();
1975
1973
unsigned TySize = Ty->getScalarSizeInBits ();
1976
1974
unsigned PtrSize = DL.getPointerSizeInBits (AS);
1977
1975
if (TySize != PtrSize) {
1978
- Type *IntPtrTy = DL.getIntPtrType (CI.getContext (), AS);
1979
- // Handle vectors of pointers.
1980
- if (auto *VecTy = dyn_cast<VectorType>(Ty))
1981
- IntPtrTy = VectorType::get (IntPtrTy, VecTy->getElementCount ());
1982
-
1976
+ Type *IntPtrTy =
1977
+ SrcTy->getWithNewType (DL.getIntPtrType (CI.getContext (), AS));
1983
1978
Value *P = Builder.CreatePtrToInt (SrcOp, IntPtrTy);
1984
1979
return CastInst::CreateIntegerCast (P, Ty, /* isSigned=*/ false );
1985
1980
}
0 commit comments