@@ -221,21 +221,27 @@ static bool performCustomAdjustments(MachineInstr &MI, unsigned NewOpc) {
221
221
}
222
222
223
223
static bool CompressEVEXImpl (MachineInstr &MI, const X86Subtarget &ST) {
224
- const MCInstrDesc &Desc = MI.getDesc ();
224
+ uint64_t TSFlags = MI.getDesc (). TSFlags ;
225
225
226
226
// Check for EVEX instructions only.
227
- if ((Desc. TSFlags & X86II::EncodingMask) != X86II::EVEX)
227
+ if ((TSFlags & X86II::EncodingMask) != X86II::EVEX)
228
228
return false ;
229
229
230
- // Check for EVEX instructions with mask or broadcast as in these cases
231
- // the EVEX prefix is needed in order to carry this information
232
- // thus preventing the transformation to VEX encoding.
233
- if (Desc.TSFlags & (X86II::EVEX_K | X86II::EVEX_B))
230
+ // Instructions with mask or 512-bit vector can't be converted to VEX.
231
+ if (TSFlags & (X86II::EVEX_K | X86II::EVEX_L2))
234
232
return false ;
235
233
236
- // Check for EVEX instructions with L2 set. These instructions are 512-bits
237
- // and can't be converted to VEX.
238
- if (Desc.TSFlags & X86II::EVEX_L2)
234
+ // EVEX_B has several meanings.
235
+ // AVX512:
236
+ // register form: rounding control or SAE
237
+ // memory form: broadcast
238
+ //
239
+ // APX:
240
+ // MAP4: NDD
241
+ //
242
+ // For AVX512 cases, EVEX prefix is needed in order to carry this information
243
+ // thus preventing the transformation to VEX encoding.
244
+ if (TSFlags & X86II::EVEX_B)
239
245
return false ;
240
246
241
247
ArrayRef<X86CompressEVEXTableEntry> Table = ArrayRef (X86CompressEVEXTable);
@@ -245,11 +251,8 @@ static bool CompressEVEXImpl(MachineInstr &MI, const X86Subtarget &ST) {
245
251
if (I == Table.end () || I->OldOpc != Opc)
246
252
return false ;
247
253
248
- if (usesExtendedRegister (MI))
249
- return false ;
250
- if (!checkVEXInstPredicate (Opc, ST))
251
- return false ;
252
- if (!performCustomAdjustments (MI, I->NewOpc ))
254
+ if (usesExtendedRegister (MI) || !checkVEXInstPredicate (Opc, ST) ||
255
+ !performCustomAdjustments (MI, I->NewOpc ))
253
256
return false ;
254
257
255
258
const MCInstrDesc &NewDesc = ST.getInstrInfo ()->get (I->NewOpc );
@@ -272,7 +275,7 @@ bool CompressEVEXPass::runOnMachineFunction(MachineFunction &MF) {
272
275
}
273
276
#endif
274
277
const X86Subtarget &ST = MF.getSubtarget <X86Subtarget>();
275
- if (!ST.hasAVX512 () && !ST.hasEGPR ())
278
+ if (!ST.hasAVX512 () && !ST.hasEGPR () && !ST. hasNDD () )
276
279
return false ;
277
280
278
281
bool Changed = false ;
0 commit comments