Skip to content

Commit 7721be3

Browse files
committed
[TableGen] Fix calculation of Lanemask for RCs with artificial subregs.
TableGen builds up a map of "SubRegIdx -> Subclass" where Subclass is the largest class where all registers have SubRegIdx as a sub-register. When SubRegIdx (vis-a-vis the sub-register) is artificial it should still include it in the map. This map is used in various places, including in the calculation of the Lanemask of a register class, which otherwise calculates an incorrect lanemask.
1 parent 3cfdc3f commit 7721be3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

llvm/test/TableGen/ArtificialSubregs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def TestTarget : Target;
9292
// CHECK-NEXT: SpillSize: { Default:64 }
9393
// CHECK-NEXT: SpillAlignment: { Default:64 }
9494
// CHECK-NEXT: NumRegs: 3
95-
// CHECK-NEXT: LaneMask: 0000000000000008
95+
// CHECK-NEXT: LaneMask: 0000000000000088
9696
// CHECK-NEXT: HasDisjunctSubRegs: 1
9797
// CHECK-NEXT: CoveredBySubRegs: 1
9898
// CHECK-NEXT: Allocatable: 1
@@ -131,7 +131,7 @@ def TestTarget : Target;
131131
// CHECK-NEXT: SpillSize: { Default:128 }
132132
// CHECK-NEXT: SpillAlignment: { Default:128 }
133133
// CHECK-NEXT: NumRegs: 3
134-
// CHECK-NEXT: LaneMask: 0000000000000088
134+
// CHECK-NEXT: LaneMask: 0000000000000089
135135
// CHECK-NEXT: HasDisjunctSubRegs: 1
136136
// CHECK-NEXT: CoveredBySubRegs: 1
137137
// CHECK-NEXT: Allocatable: 1

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,10 +2296,8 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
22962296
if (R->Artificial)
22972297
continue;
22982298
const CodeGenRegister::SubRegMap &SRM = R->getSubRegs();
2299-
for (auto I : SRM) {
2300-
if (!I.first->Artificial)
2301-
SRSets[I.first].push_back(R);
2302-
}
2299+
for (auto I : SRM)
2300+
SRSets[I.first].push_back(R);
23032301
}
23042302

23052303
for (auto I : SRSets)
@@ -2308,8 +2306,6 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
23082306
// Find matching classes for all SRSets entries. Iterate in SubRegIndex
23092307
// numerical order to visit synthetic indices last.
23102308
for (const auto &SubIdx : SubRegIndices) {
2311-
if (SubIdx.Artificial)
2312-
continue;
23132309
SubReg2SetMap::const_iterator I = SRSets.find(&SubIdx);
23142310
// Unsupported SubRegIndex. Skip it.
23152311
if (I == SRSets.end())
@@ -2319,6 +2315,8 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
23192315
RC->setSubClassWithSubReg(&SubIdx, RC);
23202316
continue;
23212317
}
2318+
if (SubIdx.Artificial)
2319+
continue;
23222320
// This is a real subset. See if we have a matching class.
23232321
CodeGenRegisterClass *SubRC = getOrCreateSubClass(
23242322
RC, &I->second, RC->getName() + "_with_" + I->first->getName());

0 commit comments

Comments
 (0)