Skip to content

Commit

Permalink
[X86] Return more accurate getNumSupportedRegs() (NFC) (#71690)
Browse files Browse the repository at this point in the history
llvm/llvm-project#70222 introduced a hook to
return a more accurate number of registers supported for a specific
subtarget (rather than target). However, while x86 registers were
reordered to allow using this, the implementation currently still always
returns NUM_TARGET_REGS.

Adjust it to return a smaller number of registers depending on
availability of avx/avx512/amx.

The actual impact of this seems to be pretty small, on the order of
0.05%.
  • Loading branch information
nikic authored and zahiraam committed Nov 20, 2023
1 parent 1e0d3a6 commit 4f3ccd4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion llvm/lib/Target/X86/X86RegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,15 @@ unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
(X86::K6_K7 + 1 == X86::TMMCFG) &&
(X86::TMM7 + 1 == X86::NUM_TARGET_REGS) &&
"Register number may be incorrect");
return X86::NUM_TARGET_REGS;

const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
if (ST.hasAMXTILE())
return X86::TMM7 + 1;
if (ST.hasAVX512())
return X86::K6_K7 + 1;
if (ST.hasAVX())
return X86::YMM15 + 1;
return X86::R15WH + 1;
}

bool X86RegisterInfo::isArgumentRegister(const MachineFunction &MF,
Expand Down

0 comments on commit 4f3ccd4

Please sign in to comment.