Skip to content

Commit 3254a00

Browse files
[SVE] Remove usages of VectorType::getNumElements() from AMDGPU
Reviewers: efriedma, arsenm, david-arm, fpetrogalli Reviewed By: efriedma Subscribers: dmgreen, arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, tschuett, hiraditya, rkruppe, psnobl, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79807
1 parent 824a859 commit 3254a00

9 files changed

+21
-22
lines changed

llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Type *AMDGPUCodeGenPrepare::getI32Ty(IRBuilder<> &B, const Type *T) const {
255255

256256
if (T->isIntegerTy())
257257
return B.getInt32Ty();
258-
return VectorType::get(B.getInt32Ty(), cast<VectorType>(T)->getNumElements());
258+
return FixedVectorType::get(B.getInt32Ty(), cast<FixedVectorType>(T));
259259
}
260260

261261
bool AMDGPUCodeGenPrepare::isSigned(const BinaryOperator &I) const {
@@ -477,7 +477,7 @@ bool AMDGPUCodeGenPrepare::isU24(Value *V, unsigned ScalarSize) const {
477477

478478
static void extractValues(IRBuilder<> &Builder,
479479
SmallVectorImpl<Value *> &Values, Value *V) {
480-
VectorType *VT = dyn_cast<VectorType>(V->getType());
480+
auto *VT = dyn_cast<FixedVectorType>(V->getType());
481481
if (!VT) {
482482
Values.push_back(V);
483483
return;
@@ -777,7 +777,7 @@ bool AMDGPUCodeGenPrepare::visitFDiv(BinaryOperator &FDiv) {
777777
Value *Den = FDiv.getOperand(1);
778778

779779
Value *NewFDiv = nullptr;
780-
if (VectorType *VT = dyn_cast<VectorType>(FDiv.getType())) {
780+
if (auto *VT = dyn_cast<FixedVectorType>(FDiv.getType())) {
781781
NewFDiv = UndefValue::get(VT);
782782

783783
// FIXME: Doesn't do the right thing for cases where the vector is partially
@@ -1233,7 +1233,7 @@ bool AMDGPUCodeGenPrepare::visitBinaryOperator(BinaryOperator &I) {
12331233
IRBuilder<> Builder(&I);
12341234
Builder.SetCurrentDebugLocation(I.getDebugLoc());
12351235

1236-
if (VectorType *VT = dyn_cast<VectorType>(Ty)) {
1236+
if (auto *VT = dyn_cast<FixedVectorType>(Ty)) {
12371237
NewDiv = UndefValue::get(VT);
12381238

12391239
for (unsigned N = 0, E = VT->getNumElements(); N != E; ++N) {

llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ std::string MetadataStreamerV2::getTypeName(Type *Ty, bool Signed) const {
186186
case Type::DoubleTyID:
187187
return "double";
188188
case Type::FixedVectorTyID: {
189-
auto VecTy = cast<VectorType>(Ty);
189+
auto VecTy = cast<FixedVectorType>(Ty);
190190
auto ElTy = VecTy->getElementType();
191191
auto NumElements = VecTy->getNumElements();
192192
return (Twine(getTypeName(ElTy, Signed)) + Twine(NumElements)).str();
@@ -633,7 +633,7 @@ std::string MetadataStreamerV3::getTypeName(Type *Ty, bool Signed) const {
633633
case Type::DoubleTyID:
634634
return "double";
635635
case Type::FixedVectorTyID: {
636-
auto VecTy = cast<VectorType>(Ty);
636+
auto VecTy = cast<FixedVectorType>(Ty);
637637
auto ElTy = VecTy->getElementType();
638638
auto NumElements = VecTy->getNumElements();
639639
return (Twine(getTypeName(ElTy, Signed)) + Twine(NumElements)).str();

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,8 @@ bool AMDGPULibCalls::fold_pow(CallInst *CI, IRBuilder<> &B,
11261126
Type* rTy = opr0->getType();
11271127
Type* nTyS = eltType->isDoubleTy() ? B.getInt64Ty() : B.getInt32Ty();
11281128
Type *nTy = nTyS;
1129-
if (const VectorType *vTy = dyn_cast<VectorType>(rTy))
1130-
nTy = VectorType::get(nTyS, vTy->getNumElements());
1129+
if (const auto *vTy = dyn_cast<FixedVectorType>(rTy))
1130+
nTy = FixedVectorType::get(nTyS, vTy);
11311131
unsigned size = nTy->getScalarSizeInBits();
11321132
opr_n = CI->getArgOperand(1);
11331133
if (opr_n->getType()->isIntegerTy())

llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ bool AMDGPULowerKernelArguments::runOnFunction(Function &F) {
135135
continue;
136136
}
137137

138-
VectorType *VT = dyn_cast<VectorType>(ArgTy);
138+
auto *VT = dyn_cast<FixedVectorType>(ArgTy);
139139
bool IsV3 = VT && VT->getNumElements() == 3;
140140
bool DoShiftOpt = Size < 32 && !ArgTy->isAggregateType();
141141

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
218218
//
219219
if (ArgSize % DWORD_ALIGN != 0) {
220220
llvm::Type *ResType = llvm::Type::getInt32Ty(Ctx);
221-
VectorType *LLVMVecType = llvm::dyn_cast<llvm::VectorType>(ArgType);
221+
auto *LLVMVecType = llvm::dyn_cast<llvm::FixedVectorType>(ArgType);
222222
int NumElem = LLVMVecType ? LLVMVecType->getNumElements() : 1;
223223
if (LLVMVecType && NumElem > 1)
224-
ResType = llvm::VectorType::get(ResType, NumElem);
224+
ResType = llvm::FixedVectorType::get(ResType, NumElem);
225225
Builder.SetInsertPoint(CI);
226226
Builder.SetCurrentDebugLocation(CI->getDebugLoc());
227227
if (OpConvSpecifiers[ArgCount - 1] == 'x' ||
@@ -479,7 +479,7 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
479479
}
480480
} else if (isa<FixedVectorType>(ArgType)) {
481481
Type *IType = NULL;
482-
uint32_t EleCount = cast<VectorType>(ArgType)->getNumElements();
482+
uint32_t EleCount = cast<FixedVectorType>(ArgType)->getNumElements();
483483
uint32_t EleSize = ArgType->getScalarSizeInBits();
484484
uint32_t TotalSize = EleCount * EleSize;
485485
if (EleCount == 3) {

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ Value *AMDGPUPromoteAlloca::getWorkitemID(IRBuilder<> &Builder, unsigned N) {
297297
return CI;
298298
}
299299

300-
static VectorType *arrayTypeToVecType(ArrayType *ArrayTy) {
301-
return VectorType::get(ArrayTy->getElementType(),
302-
ArrayTy->getNumElements());
300+
static FixedVectorType *arrayTypeToVecType(ArrayType *ArrayTy) {
301+
return FixedVectorType::get(ArrayTy->getElementType(),
302+
ArrayTy->getNumElements());
303303
}
304304

305305
static Value *stripBitcasts(Value *V) {
@@ -390,7 +390,7 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca, const DataLayout &DL) {
390390
}
391391

392392
Type *AllocaTy = Alloca->getAllocatedType();
393-
VectorType *VectorTy = dyn_cast<VectorType>(AllocaTy);
393+
auto *VectorTy = dyn_cast<FixedVectorType>(AllocaTy);
394394
if (auto *ArrayTy = dyn_cast<ArrayType>(AllocaTy)) {
395395
if (VectorType::isValidElementType(ArrayTy->getElementType()) &&
396396
ArrayTy->getNumElements() > 0)

llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ bool AMDGPURewriteOutArguments::doInitialization(Module &M) {
208208

209209
#ifndef NDEBUG
210210
bool AMDGPURewriteOutArguments::isVec3ToVec4Shuffle(Type *Ty0, Type* Ty1) const {
211-
VectorType *VT0 = dyn_cast<VectorType>(Ty0);
212-
VectorType *VT1 = dyn_cast<VectorType>(Ty1);
211+
auto *VT0 = dyn_cast<FixedVectorType>(Ty0);
212+
auto *VT1 = dyn_cast<FixedVectorType>(Ty1);
213213
if (!VT0 || !VT1)
214214
return false;
215215

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ bool GCNTTIImpl::rewriteIntrinsicWithAddressSpace(
909909
unsigned GCNTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, VectorType *VT,
910910
int Index, VectorType *SubTp) {
911911
if (ST->hasVOP3PInsts()) {
912-
if (VT->getNumElements() == 2 &&
912+
if (cast<FixedVectorType>(VT)->getNumElements() == 2 &&
913913
DL.getTypeSizeInBits(VT->getElementType()) == 16) {
914914
// With op_sel VOP3P instructions freely can access the low half or high
915915
// half of a register, so any swizzle is free.

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,8 @@ unsigned SITargetLowering::getVectorTypeBreakdownForCallingConv(
938938
static EVT memVTFromImageData(Type *Ty, unsigned DMaskLanes) {
939939
assert(DMaskLanes != 0);
940940

941-
if (auto *VT = dyn_cast<VectorType>(Ty)) {
942-
unsigned NumElts = std::min(DMaskLanes,
943-
static_cast<unsigned>(VT->getNumElements()));
941+
if (auto *VT = dyn_cast<FixedVectorType>(Ty)) {
942+
unsigned NumElts = std::min(DMaskLanes, VT->getNumElements());
944943
return EVT::getVectorVT(Ty->getContext(),
945944
EVT::getEVT(VT->getElementType()),
946945
NumElts);

0 commit comments

Comments
 (0)