Skip to content

Commit 89fd195

Browse files
authored
AMDGPU: Fix buffer load/store of pointers (#95379)
Make sure we test all the address spaces since this support isn't free in gisel.
1 parent 76894c5 commit 89fd195

File tree

3 files changed

+1071
-12
lines changed

3 files changed

+1071
-12
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,29 +1114,33 @@ unsigned SITargetLowering::getVectorTypeBreakdownForCallingConv(
11141114
Context, CC, VT, IntermediateVT, NumIntermediates, RegisterVT);
11151115
}
11161116

1117-
static EVT memVTFromLoadIntrData(Type *Ty, unsigned MaxNumLanes) {
1117+
static EVT memVTFromLoadIntrData(const SITargetLowering &TLI,
1118+
const DataLayout &DL, Type *Ty,
1119+
unsigned MaxNumLanes) {
11181120
assert(MaxNumLanes != 0);
11191121

1122+
LLVMContext &Ctx = Ty->getContext();
11201123
if (auto *VT = dyn_cast<FixedVectorType>(Ty)) {
11211124
unsigned NumElts = std::min(MaxNumLanes, VT->getNumElements());
1122-
return EVT::getVectorVT(Ty->getContext(),
1123-
EVT::getEVT(VT->getElementType()),
1125+
return EVT::getVectorVT(Ctx, TLI.getValueType(DL, VT->getElementType()),
11241126
NumElts);
11251127
}
11261128

1127-
return EVT::getEVT(Ty);
1129+
return TLI.getValueType(DL, Ty);
11281130
}
11291131

11301132
// Peek through TFE struct returns to only use the data size.
1131-
static EVT memVTFromLoadIntrReturn(Type *Ty, unsigned MaxNumLanes) {
1133+
static EVT memVTFromLoadIntrReturn(const SITargetLowering &TLI,
1134+
const DataLayout &DL, Type *Ty,
1135+
unsigned MaxNumLanes) {
11321136
auto *ST = dyn_cast<StructType>(Ty);
11331137
if (!ST)
1134-
return memVTFromLoadIntrData(Ty, MaxNumLanes);
1138+
return memVTFromLoadIntrData(TLI, DL, Ty, MaxNumLanes);
11351139

11361140
// TFE intrinsics return an aggregate type.
11371141
assert(ST->getNumContainedTypes() == 2 &&
11381142
ST->getContainedType(1)->isIntegerTy(32));
1139-
return memVTFromLoadIntrData(ST->getContainedType(0), MaxNumLanes);
1143+
return memVTFromLoadIntrData(TLI, DL, ST->getContainedType(0), MaxNumLanes);
11401144
}
11411145

11421146
/// Map address space 7 to MVT::v5i32 because that's its in-memory
@@ -1221,10 +1225,12 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
12211225
MaxNumLanes = DMask == 0 ? 1 : llvm::popcount(DMask);
12221226
}
12231227

1224-
Info.memVT = memVTFromLoadIntrReturn(CI.getType(), MaxNumLanes);
1228+
Info.memVT = memVTFromLoadIntrReturn(*this, MF.getDataLayout(),
1229+
CI.getType(), MaxNumLanes);
12251230
} else {
1226-
Info.memVT = memVTFromLoadIntrReturn(
1227-
CI.getType(), std::numeric_limits<unsigned>::max());
1231+
Info.memVT =
1232+
memVTFromLoadIntrReturn(*this, MF.getDataLayout(), CI.getType(),
1233+
std::numeric_limits<unsigned>::max());
12281234
}
12291235

12301236
// FIXME: What does alignment mean for an image?
@@ -1237,9 +1243,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
12371243
if (RsrcIntr->IsImage) {
12381244
unsigned DMask = cast<ConstantInt>(CI.getArgOperand(1))->getZExtValue();
12391245
unsigned DMaskLanes = DMask == 0 ? 1 : llvm::popcount(DMask);
1240-
Info.memVT = memVTFromLoadIntrData(DataTy, DMaskLanes);
1246+
Info.memVT = memVTFromLoadIntrData(*this, MF.getDataLayout(), DataTy,
1247+
DMaskLanes);
12411248
} else
1242-
Info.memVT = EVT::getEVT(DataTy);
1249+
Info.memVT = getValueType(MF.getDataLayout(), DataTy);
12431250

12441251
Info.flags |= MachineMemOperand::MOStore;
12451252
} else {

0 commit comments

Comments
 (0)