[llvm] [X86][NFC] Reorder the registers to reduce unnecessary iterations (PR #70222)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 19:33:54 PDT 2023
================
@@ -616,6 +616,32 @@ BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
return Reserved;
}
+unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
+ const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
+ // All existing Intel CPUs that support AMX support AVX512 and all existing
+ // Intel CPUs that support APX support AMX. AVX512 implies AVX.
+ //
+ // We enumerate the registers in X86GenRegisterInfo.inc in this order:
+ //
+ // Registers before AVX512,
+ // AVX512 registers (X/YMM16-31, ZMM0-31, K registers)
+ // AMX registers (TMM)
+ // APX registers (R16-R31)
+ //
+ // and try to return the minimum number of registers supported by the target.
+
+ bool HasAVX = ST.hasAVX();
+ bool HasAVX512 = ST.hasAVX512();
+ bool HasAMX = ST.hasAMXTILE();
+ if (HasAMX)
+ return X86::TMM7 + 1;
+ if (HasAVX512)
+ return X86::K6_K7 + 1;
+ if (HasAVX)
+ return X86::YMM15 + 1;
+ return X86::YMM0;
----------------
phoebewang wrote:
Is there any way to avoid to hard code it?
If not, I think you'd better to add assert to make sure the number is the boundary, e.g.,
`assert(X86::YMM15 + 1 == X86:K0, "Register number may not correct");`
https://github.com/llvm/llvm-project/pull/70222
More information about the llvm-commits
mailing list