Skip to content

Commit 303e1c8

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 7f7736a commit 303e1c8

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
@@ -104,15 +104,15 @@ def TestTarget : Target;
104104
// CHECK: SuperClasses:
105105
//
106106
// CHECK: RegisterClass DRegs:
107-
// CHECK: LaneMask: 0000000000000004
107+
// CHECK: LaneMask: 0000000000000044
108108
// CHECK: HasDisjunctSubRegs: 1
109109
// CHECK: CoveredBySubRegs: 1
110110
// CHECK: Regs: D0 D1 D2
111111
// CHECK: SubClasses: DRegs
112112
// CHECK: SuperClasses:
113113
//
114114
// CHECK: RegisterClass QRegs:
115-
// CHECK: LaneMask: 0000000000000044
115+
// CHECK: LaneMask: 0000000000000045
116116
// CHECK: HasDisjunctSubRegs: 1
117117
// CHECK: CoveredBySubRegs: 1
118118
// CHECK: Regs: Q0 Q1 Q2

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,10 +2300,8 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
23002300
if (R->Artificial)
23012301
continue;
23022302
const CodeGenRegister::SubRegMap &SRM = R->getSubRegs();
2303-
for (auto I : SRM) {
2304-
if (!I.first->Artificial)
2305-
SRSets[I.first].push_back(R);
2306-
}
2303+
for (auto I : SRM)
2304+
SRSets[I.first].push_back(R);
23072305
}
23082306

23092307
for (auto I : SRSets)
@@ -2312,8 +2310,6 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
23122310
// Find matching classes for all SRSets entries. Iterate in SubRegIndex
23132311
// numerical order to visit synthetic indices last.
23142312
for (const auto &SubIdx : SubRegIndices) {
2315-
if (SubIdx.Artificial)
2316-
continue;
23172313
SubReg2SetMap::const_iterator I = SRSets.find(&SubIdx);
23182314
// Unsupported SubRegIndex. Skip it.
23192315
if (I == SRSets.end())
@@ -2323,6 +2319,8 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
23232319
RC->setSubClassWithSubReg(&SubIdx, RC);
23242320
continue;
23252321
}
2322+
if (SubIdx.Artificial)
2323+
continue;
23262324
// This is a real subset. See if we have a matching class.
23272325
CodeGenRegisterClass *SubRC = getOrCreateSubClass(
23282326
RC, &I->second, RC->getName() + "_with_" + I->first->getName());

0 commit comments

Comments
 (0)