[llvm] [LowerBufferFatPointers] Fix support for GEP T, p7, <N x T> idxs (PR #126126)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 19:49:16 PST 2025
================
@@ -1804,14 +1804,26 @@ PtrParts SplitPtrStructs::visitGetElementPtrInst(GetElementPtrInst &GEP) {
bool IsNUW = GEP.hasNoUnsignedWrap();
bool IsNUSW = GEP.hasNoUnsignedSignedWrap();
+ Type *ResTy = GEP.getType();
+ std::optional<ElementCount> ResEC;
+ if (auto *ResVT = dyn_cast<VectorType>(ResTy->getStructElementType(0)))
+ ResEC = ResVT->getElementCount();
+ bool HasPtrVecIn = isa<VectorType>(Off->getType());
+ bool BroadcastsPtr = ResEC.has_value() && !HasPtrVecIn;
+
// In order to call emitGEPOffset() and thus not have to reimplement it,
// we need the GEP result to have ptr addrspace(7) type.
Type *FatPtrTy = IRB.getPtrTy(AMDGPUAS::BUFFER_FAT_POINTER);
- if (auto *VT = dyn_cast<VectorType>(Off->getType()))
- FatPtrTy = VectorType::get(FatPtrTy, VT->getElementCount());
+ if (ResEC.has_value())
+ FatPtrTy = VectorType::get(FatPtrTy, *ResEC);
----------------
arsenm wrote:
You can use getWithNewType for the scalar or vector handling
https://github.com/llvm/llvm-project/pull/126126
More information about the llvm-commits
mailing list