Skip to content

Commit

Permalink
[X86][NFC] Avoid uselss iterations when emitting EVEX compression table
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KanRobert committed Jan 6, 2024
1 parent 0c7d46a commit 61bb3d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86CompressEVEX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//
// Possible compression:
// a. AVX512 instruction (EVEX) -> AVX instruction (VEX)
// b. Promoted instruction (EVEX) -> pre-promotion instruction (legacy)
// b. Promoted instruction (EVEX) -> pre-promotion instruction (legacy/VEX)
// c. NDD (EVEX) -> non-NDD (legacy)
// d. NF_ND (EVEX) -> NF (EVEX)
//
Expand Down Expand Up @@ -272,7 +272,7 @@ bool CompressEVEXPass::runOnMachineFunction(MachineFunction &MF) {
}
#endif
const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
if (!ST.hasAVX512())
if (!ST.hasAVX512() && !ST.hasEGPR())
return false;

bool Changed = false;
Expand Down
12 changes: 11 additions & 1 deletion llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,17 @@ void X86CompressEVEXTablesEmitter::run(raw_ostream &OS) {
for (const CodeGenInstruction *Inst : NumberedInstructions) {
const Record *Rec = Inst->TheDef;
// _REV instruction should not appear before encoding optimization
if (!Rec->isSubClassOf("X86Inst") || Rec->getName().ends_with("_REV"))
if (!Rec->isSubClassOf("X86Inst") ||
Rec->getValueAsBit("isAsmParserOnly") ||
Rec->getName().ends_with("_REV"))
continue;

// Promoted legacy instruction is in EVEX space, and has REX2-encoding
// alternative. It's added due to HW design and never emitted by compiler.
if (byteFromBitsInit(Rec->getValueAsBitsInit("OpMapBits")) ==
X86Local::T_MAP4 &&
byteFromBitsInit(Rec->getValueAsBitsInit("explicitOpPrefixBits")) ==
X86Local::ExplicitEVEX)
continue;

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

0 comments on commit 61bb3d4

Please sign in to comment.