Skip to content

Commit 65b8b64

Browse files
Clean up usages of asserting vector getters in Type
Summary: Remove usages of asserting vector getters in Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: sdesmalen, efriedma, jonpa Reviewed By: sdesmalen Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77265
1 parent a88cc20 commit 65b8b64

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ static unsigned getScalarSizeInBits(Type *Ty) {
359359
// 3.
360360
static unsigned getNumVectorRegs(Type *Ty) {
361361
assert(Ty->isVectorTy() && "Expected vector type");
362-
unsigned WideBits = getScalarSizeInBits(Ty) * Ty->getVectorNumElements();
362+
unsigned WideBits =
363+
getScalarSizeInBits(Ty) * cast<VectorType>(Ty)->getNumElements();
363364
assert(WideBits > 0 && "Could not compute size of vector");
364365
return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U));
365366
}
@@ -459,7 +460,7 @@ int SystemZTTIImpl::getArithmeticInstrCost(
459460
return DivInstrCost;
460461
}
461462
else if (ST->hasVector()) {
462-
unsigned VF = Ty->getVectorNumElements();
463+
unsigned VF = cast<VectorType>(Ty)->getNumElements();
463464
unsigned NumVectors = getNumVectorRegs(Ty);
464465

465466
// These vector operations are custom handled, but are still supported
@@ -580,8 +581,9 @@ getVectorTruncCost(Type *SrcTy, Type *DstTy) {
580581
assert (SrcTy->isVectorTy() && DstTy->isVectorTy());
581582
assert (SrcTy->getPrimitiveSizeInBits() > DstTy->getPrimitiveSizeInBits() &&
582583
"Packing must reduce size of vector type.");
583-
assert (SrcTy->getVectorNumElements() == DstTy->getVectorNumElements() &&
584-
"Packing should not change number of elements.");
584+
assert(cast<VectorType>(SrcTy)->getNumElements() ==
585+
cast<VectorType>(DstTy)->getNumElements() &&
586+
"Packing should not change number of elements.");
585587

586588
// TODO: Since fp32 is expanded, the extract cost should always be 0.
587589

@@ -596,7 +598,7 @@ getVectorTruncCost(Type *SrcTy, Type *DstTy) {
596598

597599
unsigned Cost = 0;
598600
unsigned Log2Diff = getElSizeLog2Diff(SrcTy, DstTy);
599-
unsigned VF = SrcTy->getVectorNumElements();
601+
unsigned VF = cast<VectorType>(SrcTy)->getNumElements();
600602
for (unsigned P = 0; P < Log2Diff; ++P) {
601603
if (NumParts > 1)
602604
NumParts /= 2;
@@ -670,7 +672,7 @@ unsigned SystemZTTIImpl::
670672
getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
671673
const Instruction *I) {
672674
assert (Dst->isVectorTy());
673-
unsigned VF = Dst->getVectorNumElements();
675+
unsigned VF = cast<VectorType>(Dst)->getNumElements();
674676
unsigned Cost = 0;
675677
// If we know what the widths of the compared operands, get any cost of
676678
// converting it to match Dst. Otherwise assume same widths.
@@ -719,7 +721,7 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
719721
}
720722
else if (ST->hasVector()) {
721723
assert (Dst->isVectorTy());
722-
unsigned VF = Src->getVectorNumElements();
724+
unsigned VF = cast<VectorType>(Src)->getNumElements();
723725
unsigned NumDstVectors = getNumVectorRegs(Dst);
724726
unsigned NumSrcVectors = getNumVectorRegs(Src);
725727

@@ -846,7 +848,7 @@ int SystemZTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
846848
}
847849
}
848850
else if (ST->hasVector()) {
849-
unsigned VF = ValTy->getVectorNumElements();
851+
unsigned VF = cast<VectorType>(ValTy)->getNumElements();
850852

851853
// Called with a compare instruction.
852854
if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
@@ -1089,7 +1091,7 @@ int SystemZTTIImpl::getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
10891091
// Return the ceiling of dividing A by B.
10901092
auto ceil = [](unsigned A, unsigned B) { return (A + B - 1) / B; };
10911093

1092-
unsigned NumElts = VecTy->getVectorNumElements();
1094+
unsigned NumElts = cast<VectorType>(VecTy)->getNumElements();
10931095
assert(Factor > 1 && NumElts % Factor == 0 && "Invalid interleave factor");
10941096
unsigned VF = NumElts / Factor;
10951097
unsigned NumEltsPerVecReg = (128U / getScalarSizeInBits(VecTy));

0 commit comments

Comments
 (0)