@@ -668,22 +668,18 @@ Value *AMDGPUSwLowerLDS::getTranslatedGlobalMemoryPtrOfLDS(Value *LoadMallocPtr,
668668 Value *LDSPtr) {
669669 assert (LDSPtr && " Invalid LDS pointer operand" );
670670 Type *LDSPtrType = LDSPtr->getType ();
671-
672- if (LDSPtrType->isVectorTy ()) {
671+ auto &Ctx = M.getContext ();
672+ const auto &DL = M.getDataLayout ();
673+ auto *IntPtrTy = DL.getIntPtrType (Ctx, AMDGPUAS::LOCAL_ADDRESS);
674+ if (auto *VecPtrTy = dyn_cast<VectorType>(LDSPtrType)) {
673675 // Handle vector of pointers
674- VectorType *VecPtrTy = cast<VectorType>(LDSPtrType);
675676 ElementCount NumElements = VecPtrTy->getElementCount ();
676- Type *Int32VecTy = VectorType::get (IRB. getInt32Ty () , NumElements);
677- Value *PtrToInt = IRB.CreatePtrToInt (LDSPtr, Int32VecTy );
677+ Type *IntVecTy = VectorType::get (IntPtrTy , NumElements);
678+ Value *PtrToInt = IRB.CreatePtrToInt (LDSPtr, IntVecTy );
678679 // Create vector of pointers to global address space
679- Type *GlobalPtrVecTy =
680- VectorType::get (IRB.getPtrTy (AMDGPUAS::GLOBAL_ADDRESS), NumElements);
681- Value *GlobalPtrVec =
682- IRB.CreateInBoundsGEP (IRB.getInt8Ty (), LoadMallocPtr, PtrToInt);
683- GlobalPtrVec = IRB.CreateBitCast (GlobalPtrVec, GlobalPtrVecTy);
684- return GlobalPtrVec;
680+ return IRB.CreateInBoundsGEP (IRB.getInt8Ty (), LoadMallocPtr, PtrToInt);
685681 }
686- Value *PtrToInt = IRB.CreatePtrToInt (LDSPtr, IRB. getInt32Ty () );
682+ Value *PtrToInt = IRB.CreatePtrToInt (LDSPtr, IntPtrTy );
687683 return IRB.CreateInBoundsGEP (IRB.getInt8Ty (), LoadMallocPtr, {PtrToInt});
688684}
689685
0 commit comments