Skip to content

Commit 502ad98

Browse files
committed
Reviewer suggestions
1 parent cbede57 commit 502ad98

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

llvm/lib/Target/X86/X86FastPreTileConfig.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,16 @@ void X86FastPreTileConfig::reload(MachineBasicBlock::iterator UseMI,
267267
<< printReg(TileReg, TRI) << '\n');
268268
}
269269

270-
static unsigned getTileDefNum(MachineRegisterInfo *MRI, Register Reg) {
270+
static bool isTileRegister(MachineRegisterInfo *MRI, Register Reg) {
271271
if (Reg.isVirtual() &&
272272
(MRI->getRegClass(Reg)->getID() == X86::TILERegClassID)) {
273-
return 1;
273+
return true;
274274
}
275275

276276
if (Reg >= X86::TMM0 && Reg <= X86::TMM7)
277-
return 1;
278-
279-
return 0;
280-
}
277+
return true;
281278

282-
static bool isTileRegister(MachineRegisterInfo *MRI, Register VirtReg) {
283-
return getTileDefNum(MRI, VirtReg) > 0;
279+
return false;
284280
}
285281

286282
static bool isTileDef(MachineRegisterInfo *MRI, MachineInstr &MI) {
@@ -292,7 +288,7 @@ static bool isTileDef(MachineRegisterInfo *MRI, MachineInstr &MI) {
292288
if (!MO.isReg())
293289
return false;
294290

295-
return getTileDefNum(MRI, MO.getReg()) > 0;
291+
return isTileRegister(MRI, MO.getReg());
296292
}
297293

298294
static ShapeT getShape(MachineRegisterInfo *MRI, Register TileReg) {

llvm/lib/Target/X86/X86FastTileConfig.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ INITIALIZE_PASS_BEGIN(X86FastTileConfig, DEBUG_TYPE,
7777
INITIALIZE_PASS_END(X86FastTileConfig, DEBUG_TYPE,
7878
"Fast Tile Register Configure", false, false)
7979

80-
static unsigned getNumDefTiles(MachineRegisterInfo *MRI, MachineInstr &MI) {
80+
static bool isTileDef(MachineRegisterInfo *MRI, MachineInstr &MI) {
8181
// There is no phi instruction after register allocation.
8282
assert(MI.isPHI() == false);
8383
// The instruction must have 3 operands: tile def, row, col.
8484
// It should be AMX pseudo instruction that have shape operand.
8585
if (MI.isDebugInstr() || MI.isCopy() || MI.getNumOperands() < 3 ||
8686
!MI.isPseudo())
87-
return 0;
87+
return false;
8888
MachineOperand &MO = MI.getOperand(0);
8989

9090
if (MO.isReg()) {
@@ -93,13 +93,13 @@ static unsigned getNumDefTiles(MachineRegisterInfo *MRI, MachineInstr &MI) {
9393
// register is not rewritten yet.
9494
if (Reg.isVirtual()) {
9595
if (MRI->getRegClass(Reg)->getID() == X86::TILERegClassID)
96-
return 1;
96+
return false;
9797
}
9898
if (Reg >= X86::TMM0 && Reg <= X86::TMM7)
99-
return 1;
99+
return false;
100100
}
101101

102-
return 0;
102+
return false;
103103
}
104104

105105
static unsigned getTMMIndex(Register Reg) {
@@ -114,17 +114,14 @@ bool X86FastTileConfig::configBasicBlock(MachineBasicBlock &MBB) {
114114
bool Change = false;
115115
SmallVector<std::pair<unsigned, ShapeT>, 6> ShapeInfos;
116116
for (MachineInstr &MI : reverse(MBB)) {
117-
unsigned DefNum = getNumDefTiles(MRI, MI);
118-
if (DefNum == 0 && MI.getOpcode() != X86::PLDTILECFGV)
117+
if (!isTileDef(MRI, MI) && MI.getOpcode() != X86::PLDTILECFGV)
119118
continue;
120119
// AMX instructions that define tile register.
121120
if (MI.getOpcode() != X86::PLDTILECFGV) {
122121
MachineOperand &Row = MI.getOperand(1);
123122
unsigned TMMIdx = getTMMIndex(MI.getOperand(0).getReg());
124-
for (unsigned I = 0; I < DefNum; I++) {
125-
MachineOperand &Col = MI.getOperand(2 + I);
126-
ShapeInfos.push_back({TMMIdx + I, ShapeT(&Row, &Col)});
127-
}
123+
MachineOperand &Col = MI.getOperand(2);
124+
ShapeInfos.push_back({TMMIdx, ShapeT(&Row, &Col)});
128125
} else { // PLDTILECFGV
129126
// Rewrite the shape information to memory. Stack slot should have
130127
// been initialized to zero in pre config.

llvm/lib/Target/X86/X86PreTileConfig.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class X86PreTileConfig : public MachineFunctionPass {
147147
if (!Shapes)
148148
return false;
149149

150-
collectShapeInfo(MI, Shapes);
150+
collectShapeInfo(MI);
151151
return true;
152152
}
153153

@@ -163,7 +163,7 @@ class X86PreTileConfig : public MachineFunctionPass {
163163
}
164164

165165
/// Collect the shape def information for later use.
166-
void collectShapeInfo(MachineInstr &MI, unsigned Shapes);
166+
void collectShapeInfo(MachineInstr &MI);
167167

168168
/// Try to hoist shapes definded below AMX instructions.
169169
bool hoistShapesInBB(MachineBasicBlock *MBB, SmallVectorImpl<MIRef> &Shapes) {
@@ -229,7 +229,7 @@ INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
229229
INITIALIZE_PASS_END(X86PreTileConfig, "tilepreconfig",
230230
"Tile Register Pre-configure", false, false)
231231

232-
void X86PreTileConfig::collectShapeInfo(MachineInstr &MI, unsigned Shapes) {
232+
void X86PreTileConfig::collectShapeInfo(MachineInstr &MI) {
233233
auto RecordShape = [&](MachineInstr *MI, MachineBasicBlock *MBB) {
234234
MIRef MIR(MI, MBB);
235235
auto &Refs = ShapeBBs[MBB];
@@ -238,10 +238,8 @@ void X86PreTileConfig::collectShapeInfo(MachineInstr &MI, unsigned Shapes) {
238238
Refs.insert(I, MIR);
239239
};
240240

241-
// All shapes have same row in multi-tile operand.
242-
SmallVector<Register, 8> WorkList;
243-
for (unsigned I = 1; I < Shapes + 2; ++I)
244-
WorkList.push_back(MI.getOperand(I).getReg());
241+
SmallVector<Register, 8> WorkList(
242+
{MI.getOperand(1).getReg(), MI.getOperand(2).getReg()});
245243
while (!WorkList.empty()) {
246244
Register R = WorkList.pop_back_val();
247245
MachineInstr *DefMI = MRI->getVRegDef(R);

0 commit comments

Comments
 (0)