@@ -111,34 +111,36 @@ class SDWAOperand {
111
111
MachineOperand *getReplacedOperand () const { return Replaced; }
112
112
MachineInstr *getParentInst () const { return Target->getParent (); }
113
113
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:
118
119
// / 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;
122
124
123
- if (FoldedOp == SdwaSel::DWORD)
124
- return ExistingOp ;
125
+ if (OperandSel == SdwaSel::DWORD)
126
+ return ExistingSel ;
125
127
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)
128
130
return {};
129
131
130
- if (ExistingOp == FoldedOp )
131
- return ExistingOp ;
132
+ if (ExistingSel == OperandSel )
133
+ return ExistingSel ;
132
134
133
- if (FoldedOp == SdwaSel::WORD_0)
134
- return ExistingOp ;
135
+ if (OperandSel == SdwaSel::WORD_0)
136
+ return ExistingSel ;
135
137
136
- if (FoldedOp == SdwaSel::WORD_1) {
137
- if (ExistingOp == SdwaSel::BYTE_0)
138
+ if (OperandSel == SdwaSel::WORD_1) {
139
+ if (ExistingSel == SdwaSel::BYTE_0)
138
140
return SdwaSel::BYTE_2;
139
- if (ExistingOp == SdwaSel::BYTE_1)
141
+ if (ExistingSel == SdwaSel::BYTE_1)
140
142
return SdwaSel::BYTE_3;
141
- if (ExistingOp == SdwaSel::WORD_0)
143
+ if (ExistingSel == SdwaSel::WORD_0)
142
144
return SdwaSel::WORD_1;
143
145
}
144
146
@@ -1216,13 +1218,9 @@ bool SIPeepholeSDWA::convertToSDWA(MachineInstr &MI,
1216
1218
1217
1219
MachineInstr *SDWAInst;
1218
1220
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.
1222
1221
SDWAInst = MI.getParent ()->getParent ()->CloneMachineInstr (&MI);
1223
1222
MI.getParent ()->insert (MI.getIterator (), SDWAInst);
1224
1223
} else {
1225
- // Convert to sdwa
1226
1224
SDWAInst = createSDWAVersion (MI);
1227
1225
}
1228
1226
0 commit comments