@@ -1927,11 +1927,8 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
19271927 unsigned AS = CI.getAddressSpace ();
19281928 if (CI.getOperand (0 )->getType ()->getScalarSizeInBits () !=
19291929 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));
19351932 Value *P = Builder.CreateZExtOrTrunc (CI.getOperand (0 ), Ty);
19361933 return new IntToPtrInst (P, CI.getType ());
19371934 }
@@ -1970,16 +1967,14 @@ Instruction *InstCombinerImpl::visitPtrToInt(PtrToIntInst &CI) {
19701967 // do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
19711968 // to be exposed to other transforms.
19721969 Value *SrcOp = CI.getPointerOperand ();
1970+ Type *SrcTy = SrcOp->getType ();
19731971 Type *Ty = CI.getType ();
19741972 unsigned AS = CI.getPointerAddressSpace ();
19751973 unsigned TySize = Ty->getScalarSizeInBits ();
19761974 unsigned PtrSize = DL.getPointerSizeInBits (AS);
19771975 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));
19831978 Value *P = Builder.CreatePtrToInt (SrcOp, IntPtrTy);
19841979 return CastInst::CreateIntegerCast (P, Ty, /* isSigned=*/ false );
19851980 }
0 commit comments