Skip to content

Commit 61bb3d4

Browse files
committed
[X86][NFC] Avoid uselss iterations when emitting EVEX compression table
BTW, we relax the condition for EVEX compression from ST.hasAVX512() to ST.hasEGPR() || ST.hasAVX512(). It does not have any effect now b/c no APX instruction is in the EVEX compression table so far. This patch is to extract NFC in #77065 into a separate commit.
1 parent 0c7d46a commit 61bb3d4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

llvm/lib/Target/X86/X86CompressEVEX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
// Possible compression:
1313
// a. AVX512 instruction (EVEX) -> AVX instruction (VEX)
14-
// b. Promoted instruction (EVEX) -> pre-promotion instruction (legacy)
14+
// b. Promoted instruction (EVEX) -> pre-promotion instruction (legacy/VEX)
1515
// c. NDD (EVEX) -> non-NDD (legacy)
1616
// d. NF_ND (EVEX) -> NF (EVEX)
1717
//
@@ -272,7 +272,7 @@ bool CompressEVEXPass::runOnMachineFunction(MachineFunction &MF) {
272272
}
273273
#endif
274274
const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
275-
if (!ST.hasAVX512())
275+
if (!ST.hasAVX512() && !ST.hasEGPR())
276276
return false;
277277

278278
bool Changed = false;

llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,17 @@ void X86CompressEVEXTablesEmitter::run(raw_ostream &OS) {
136136
for (const CodeGenInstruction *Inst : NumberedInstructions) {
137137
const Record *Rec = Inst->TheDef;
138138
// _REV instruction should not appear before encoding optimization
139-
if (!Rec->isSubClassOf("X86Inst") || Rec->getName().ends_with("_REV"))
139+
if (!Rec->isSubClassOf("X86Inst") ||
140+
Rec->getValueAsBit("isAsmParserOnly") ||
141+
Rec->getName().ends_with("_REV"))
142+
continue;
143+
144+
// Promoted legacy instruction is in EVEX space, and has REX2-encoding
145+
// alternative. It's added due to HW design and never emitted by compiler.
146+
if (byteFromBitsInit(Rec->getValueAsBitsInit("OpMapBits")) ==
147+
X86Local::T_MAP4 &&
148+
byteFromBitsInit(Rec->getValueAsBitsInit("explicitOpPrefixBits")) ==
149+
X86Local::ExplicitEVEX)
140150
continue;
141151

142152
if (NoCompressSet.find(Rec->getName()) != NoCompressSet.end())

0 commit comments

Comments
 (0)