@@ -221,21 +221,27 @@ static bool performCustomAdjustments(MachineInstr &MI, unsigned NewOpc) {
221221}
222222
223223static bool CompressEVEXImpl (MachineInstr &MI, const X86Subtarget &ST) {
224- const MCInstrDesc &Desc = MI.getDesc ();
224+ uint64_t TSFlags = MI.getDesc (). TSFlags ;
225225
226226 // Check for EVEX instructions only.
227- if ((Desc. TSFlags & X86II::EncodingMask) != X86II::EVEX)
227+ if ((TSFlags & X86II::EncodingMask) != X86II::EVEX)
228228 return false ;
229229
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))
234232 return false ;
235233
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)
239245 return false ;
240246
241247 ArrayRef<X86CompressEVEXTableEntry> Table = ArrayRef (X86CompressEVEXTable);
@@ -245,11 +251,8 @@ static bool CompressEVEXImpl(MachineInstr &MI, const X86Subtarget &ST) {
245251 if (I == Table.end () || I->OldOpc != Opc)
246252 return false ;
247253
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 ))
253256 return false ;
254257
255258 const MCInstrDesc &NewDesc = ST.getInstrInfo ()->get (I->NewOpc );
@@ -272,7 +275,7 @@ bool CompressEVEXPass::runOnMachineFunction(MachineFunction &MF) {
272275 }
273276#endif
274277 const X86Subtarget &ST = MF.getSubtarget <X86Subtarget>();
275- if (!ST.hasAVX512 () && !ST.hasEGPR ())
278+ if (!ST.hasAVX512 () && !ST.hasEGPR () && !ST. hasNDD () )
276279 return false ;
277280
278281 bool Changed = false ;
0 commit comments