[llvm] 228ef85 - [X86] Return more accurate getNumSupportedRegs() (NFC) (#71690)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 00:49:41 PST 2023


Author: Nikita Popov
Date: 2023-11-09T09:49:36+01:00
New Revision: 228ef85b5b6a4a42effdff7e229decabe8698797

URL: https://github.com/llvm/llvm-project/commit/228ef85b5b6a4a42effdff7e229decabe8698797
DIFF: https://github.com/llvm/llvm-project/commit/228ef85b5b6a4a42effdff7e229decabe8698797.diff

LOG: [X86] Return more accurate getNumSupportedRegs() (NFC) (#71690)

https://github.com/llvm/llvm-project/pull/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%.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86RegisterInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp
index 4fd8b6d17e862e0..b0bea42cafe11de 100644
--- a/llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -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,


        


More information about the llvm-commits mailing list