Skip to content

Commit 3242677

Browse files
committed
[AMDGPU] SIPeepholeSDWA: Change arg names and comments
1 parent c58493c commit 3242677

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,36 @@ class SDWAOperand {
111111
MachineOperand *getReplacedOperand() const { return Replaced; }
112112
MachineInstr *getParentInst() const { return Target->getParent(); }
113113

114-
/// Fold a \p FoldedOp SDWA selection into an \p ExistingOp existing SDWA
115-
/// selection. If the selections are compatible, return the combined
116-
/// selection, otherwise return a nullopt. For example, if we have existing
117-
/// BYTE_0 Sel and are attempting to fold WORD_1 Sel:
114+
/// Combine an SDWA instruction's existing SDWA selection \p
115+
/// ExistingSel with the SDWA selection \p OpSel of its operand. If
116+
/// the selections are compatible, return the combined selection,
117+
/// otherwise return a nullopt. For example, if we have ExistingSel
118+
/// = BYTE_0 Sel and FoldedSel WORD_1 Sel:
118119
/// BYTE_0 Sel (WORD_1 Sel (%X)) -> BYTE_2 Sel (%X)
119-
std::optional<SdwaSel> combineSdwaSel(SdwaSel ExistingOp, SdwaSel FoldedOp) {
120-
if (ExistingOp == SdwaSel::DWORD)
121-
return FoldedOp;
120+
std::optional<SdwaSel> combineSdwaSel(SdwaSel ExistingSel,
121+
SdwaSel OperandSel) {
122+
if (ExistingSel == SdwaSel::DWORD)
123+
return OperandSel;
122124

123-
if (FoldedOp == SdwaSel::DWORD)
124-
return ExistingOp;
125+
if (OperandSel == SdwaSel::DWORD)
126+
return ExistingSel;
125127

126-
if (ExistingOp == SdwaSel::WORD_1 || ExistingOp == SdwaSel::BYTE_2 ||
127-
ExistingOp == SdwaSel::BYTE_3)
128+
if (ExistingSel == SdwaSel::WORD_1 || ExistingSel == SdwaSel::BYTE_2 ||
129+
ExistingSel == SdwaSel::BYTE_3)
128130
return {};
129131

130-
if (ExistingOp == FoldedOp)
131-
return ExistingOp;
132+
if (ExistingSel == OperandSel)
133+
return ExistingSel;
132134

133-
if (FoldedOp == SdwaSel::WORD_0)
134-
return ExistingOp;
135+
if (OperandSel == SdwaSel::WORD_0)
136+
return ExistingSel;
135137

136-
if (FoldedOp == SdwaSel::WORD_1) {
137-
if (ExistingOp == SdwaSel::BYTE_0)
138+
if (OperandSel == SdwaSel::WORD_1) {
139+
if (ExistingSel == SdwaSel::BYTE_0)
138140
return SdwaSel::BYTE_2;
139-
if (ExistingOp == SdwaSel::BYTE_1)
141+
if (ExistingSel == SdwaSel::BYTE_1)
140142
return SdwaSel::BYTE_3;
141-
if (ExistingOp == SdwaSel::WORD_0)
143+
if (ExistingSel == SdwaSel::WORD_0)
142144
return SdwaSel::WORD_1;
143145
}
144146

@@ -1216,13 +1218,9 @@ bool SIPeepholeSDWA::convertToSDWA(MachineInstr &MI,
12161218

12171219
MachineInstr *SDWAInst;
12181220
if (TII->isSDWA(MI.getOpcode())) {
1219-
// No conversion necessary, since MI is an SDWA instruction. But
1220-
// tell convertToSDWA below to combine selections of this instruction
1221-
// and its SDWA operands.
12221221
SDWAInst = MI.getParent()->getParent()->CloneMachineInstr(&MI);
12231222
MI.getParent()->insert(MI.getIterator(), SDWAInst);
12241223
} else {
1225-
// Convert to sdwa
12261224
SDWAInst = createSDWAVersion(MI);
12271225
}
12281226

0 commit comments

Comments
 (0)