Skip to content

Commit 228ef85

Browse files
authored
[X86] Return more accurate getNumSupportedRegs() (NFC) (#71690)
#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%.
1 parent 14b5abb commit 228ef85

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,15 @@ unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
634634
(X86::K6_K7 + 1 == X86::TMMCFG) &&
635635
(X86::TMM7 + 1 == X86::NUM_TARGET_REGS) &&
636636
"Register number may be incorrect");
637-
return X86::NUM_TARGET_REGS;
637+
638+
const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
639+
if (ST.hasAMXTILE())
640+
return X86::TMM7 + 1;
641+
if (ST.hasAVX512())
642+
return X86::K6_K7 + 1;
643+
if (ST.hasAVX())
644+
return X86::YMM15 + 1;
645+
return X86::R15WH + 1;
638646
}
639647

640648
bool X86RegisterInfo::isArgumentRegister(const MachineFunction &MF,

0 commit comments

Comments
 (0)