Skip to content

Commit d345599

Browse files
[GISEL][NFC] Use getElementCount instead of getNumElements in more places
These cases in particular are done as a precommit to support legalization, regbank selection, and instruction selection for extends, splat vectors, and integer compares in #85938.
1 parent 373d875 commit d345599

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ static bool mutationIsSane(const LegalizeRule &Rule,
154154
case WidenScalar: {
155155
if (OldTy.isVector()) {
156156
// Number of elements should not change.
157-
if (!NewTy.isVector() || OldTy.getNumElements() != NewTy.getNumElements())
157+
if (!NewTy.isVector() ||
158+
OldTy.getElementCount() != NewTy.getElementCount())
158159
return false;
159160
} else {
160161
// Both types must be vectors

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ void MachineIRBuilder::validateSelectOp(const LLT ResTy, const LLT TstTy,
11601160
else
11611161
assert((TstTy.isScalar() ||
11621162
(TstTy.isVector() &&
1163-
TstTy.getNumElements() == Op0Ty.getNumElements())) &&
1163+
TstTy.getElementCount() == Op0Ty.getElementCount())) &&
11641164
"type mismatch");
11651165
#endif
11661166
}

llvm/lib/CodeGen/LowLevelTypeUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ MVT llvm::getMVTForLLT(LLT Ty) {
5151

5252
return MVT::getVectorVT(
5353
MVT::getIntegerVT(Ty.getElementType().getSizeInBits()),
54-
Ty.getNumElements());
54+
Ty.getElementCount());
5555
}
5656

5757
EVT llvm::getApproximateEVTForLLT(LLT Ty, const DataLayout &DL,

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,8 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
15061506
LLT SrcTy = MRI->getType(MI->getOperand(2).getReg());
15071507

15081508
if ((DstTy.isVector() != SrcTy.isVector()) ||
1509-
(DstTy.isVector() && DstTy.getNumElements() != SrcTy.getNumElements()))
1509+
(DstTy.isVector() &&
1510+
DstTy.getElementCount() != SrcTy.getElementCount()))
15101511
report("Generic vector icmp/fcmp must preserve number of lanes", MI);
15111512

15121513
break;

llvm/lib/CodeGen/RegisterBankInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,10 @@ void RegisterBankInfo::applyDefaultMapping(const OperandsMapper &OpdMapper) {
484484
// the storage. However, right now we don't necessarily bump all
485485
// the types to storage size. For instance, we can consider
486486
// s16 G_AND legal whereas the storage size is going to be 32.
487-
assert(OrigTy.getSizeInBits() <= NewTy.getSizeInBits() &&
488-
"Types with difference size cannot be handled by the default "
489-
"mapping");
487+
assert(
488+
TypeSize::isKnownLE(OrigTy.getSizeInBits(), NewTy.getSizeInBits()) &&
489+
"Types with difference size cannot be handled by the default "
490+
"mapping");
490491
LLVM_DEBUG(dbgs() << "\nChange type of new opd from " << NewTy << " to "
491492
<< OrigTy);
492493
MRI.setType(NewReg, OrigTy);

0 commit comments

Comments
 (0)