[compiler-rt] [clang] [llvm] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)
Freddy Ye via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 21:28:11 PST 2024
================
@@ -173,85 +173,84 @@ X86_FEATURE_COMPAT(AVX512VNNI, "avx512vnni", 34)
X86_FEATURE_COMPAT(AVX512BITALG, "avx512bitalg", 35)
X86_FEATURE_COMPAT(AVX512BF16, "avx512bf16", 36)
X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE (3DNOW, "3dnow")
+X86_FEATURE_COMPAT(3DNOW, "3dnow", 0)
X86_FEATURE (3DNOWA, "3dnowa")
+X86_FEATURE_COMPAT(ADX, "adx", 0)
X86_FEATURE (64BIT, "64bit")
-X86_FEATURE (ADX, "adx")
-X86_FEATURE (AMX_BF16, "amx-bf16")
-X86_FEATURE (AMX_COMPLEX, "amx-complex")
-X86_FEATURE (AMX_INT8, "amx-int8")
-X86_FEATURE (AMX_TILE, "amx-tile")
-X86_FEATURE (CLDEMOTE, "cldemote")
-X86_FEATURE (CLFLUSHOPT, "clflushopt")
-X86_FEATURE (CLWB, "clwb")
-X86_FEATURE_COMPAT(F16C, "f16c", 38)
-X86_FEATURE (CLZERO, "clzero")
-X86_FEATURE (CMPXCHG16B, "cx16")
-X86_FEATURE (CMPXCHG8B, "cx8")
+X86_FEATURE_COMPAT(CLDEMOTE, "cldemote", 0)
+X86_FEATURE_COMPAT(CLFLUSHOPT, "clflushopt", 0)
+X86_FEATURE_COMPAT(CLWB, "clwb", 0)
+X86_FEATURE_COMPAT(CLZERO, "clzero", 0)
+X86_FEATURE_COMPAT(CMPXCHG16B, "cx16", 0)
+X86_FEATURE_COMPAT(CMPXCHG8B, "cx8", 0)
+X86_FEATURE_COMPAT(ENQCMD, "enqcmd", 0)
+X86_FEATURE_COMPAT(F16C, "f16c", 0)
+X86_FEATURE_COMPAT(FSGSBASE, "fsgsbase", 0)
X86_FEATURE (CRC32, "crc32")
-X86_FEATURE (ENQCMD, "enqcmd")
-X86_FEATURE (FSGSBASE, "fsgsbase")
-X86_FEATURE (FXSR, "fxsr")
X86_FEATURE (INVPCID, "invpcid")
-X86_FEATURE (KL, "kl")
-X86_FEATURE (WIDEKL, "widekl")
-X86_FEATURE (LWP, "lwp")
-X86_FEATURE (LZCNT, "lzcnt")
-X86_FEATURE (MOVBE, "movbe")
-X86_FEATURE (MOVDIR64B, "movdir64b")
-X86_FEATURE (MOVDIRI, "movdiri")
-X86_FEATURE (MWAITX, "mwaitx")
-X86_FEATURE (PCONFIG, "pconfig")
-X86_FEATURE (PKU, "pku")
-X86_FEATURE (PREFETCHI, "prefetchi")
-X86_FEATURE (PREFETCHWT1, "prefetchwt1")
-X86_FEATURE (PRFCHW, "prfchw")
-X86_FEATURE (PTWRITE, "ptwrite")
-X86_FEATURE (RDPID, "rdpid")
X86_FEATURE (RDPRU, "rdpru")
-X86_FEATURE (RDRND, "rdrnd")
-X86_FEATURE (RDSEED, "rdseed")
-X86_FEATURE (RTM, "rtm")
X86_FEATURE (SAHF, "sahf")
-X86_FEATURE (SERIALIZE, "serialize")
-X86_FEATURE (SGX, "sgx")
-X86_FEATURE (SHA, "sha")
-X86_FEATURE (SHSTK, "shstk")
-X86_FEATURE (TBM, "tbm")
-X86_FEATURE (TSXLDTRK, "tsxldtrk")
-X86_FEATURE (UINTR, "uintr")
-X86_FEATURE (VAES, "vaes")
X86_FEATURE (VZEROUPPER, "vzeroupper")
-X86_FEATURE (WAITPKG, "waitpkg")
-X86_FEATURE (WBNOINVD, "wbnoinvd")
+X86_FEATURE_COMPAT(LWP, "lwp", 0)
+X86_FEATURE_COMPAT(LZCNT, "lzcnt", 0)
+X86_FEATURE_COMPAT(MOVBE, "movbe", 0)
+X86_FEATURE_COMPAT(MOVDIR64B, "movdir64b", 0)
+X86_FEATURE_COMPAT(MOVDIRI, "movdiri", 0)
+X86_FEATURE_COMPAT(MWAITX, "mwaitx", 0)
X86_FEATURE (X87, "x87")
-X86_FEATURE (XSAVE, "xsave")
-X86_FEATURE (XSAVEC, "xsavec")
-X86_FEATURE (XSAVEOPT, "xsaveopt")
-X86_FEATURE (XSAVES, "xsaves")
-X86_FEATURE_COMPAT(AVX512FP16, "avx512fp16", 39)
-X86_FEATURE (HRESET, "hreset")
-X86_FEATURE (RAOINT, "raoint")
-X86_FEATURE (AMX_FP16, "amx-fp16")
-X86_FEATURE (CMPCCXADD, "cmpccxadd")
-X86_FEATURE (AVXNECONVERT, "avxneconvert")
-X86_FEATURE (AVXVNNI, "avxvnni")
-X86_FEATURE (AVXIFMA, "avxifma")
-X86_FEATURE (AVXVNNIINT8, "avxvnniint8")
-X86_FEATURE (SHA512, "sha512")
-X86_FEATURE (SM3, "sm3")
-X86_FEATURE (SM4, "sm4")
-X86_FEATURE (AVXVNNIINT16, "avxvnniint16")
-X86_FEATURE (EVEX512, "evex512")
-X86_FEATURE (AVX10_1, "avx10.1-256")
-X86_FEATURE (AVX10_1_512, "avx10.1-512")
-X86_FEATURE (USERMSR, "usermsr")
-X86_FEATURE (EGPR, "egpr")
+X86_FEATURE_COMPAT(PCONFIG, "pconfig", 0)
+X86_FEATURE_COMPAT(PKU, "pku", 0)
+X86_FEATURE_COMPAT(PREFETCHWT1, "prefetchwt1", 0)
+X86_FEATURE_COMPAT(PRFCHW, "prfchw", 0)
+X86_FEATURE_COMPAT(PTWRITE, "ptwrite", 0)
+X86_FEATURE_COMPAT(RDPID, "rdpid", 0)
+X86_FEATURE_COMPAT(RDRND, "rdrnd", 0)
+X86_FEATURE_COMPAT(RDSEED, "rdseed", 0)
+X86_FEATURE_COMPAT(RTM, "rtm", 0)
+X86_FEATURE_COMPAT(SERIALIZE, "serialize", 0)
+X86_FEATURE_COMPAT(SGX, "sgx", 0)
+X86_FEATURE_COMPAT(SHA, "sha", 0)
+X86_FEATURE_COMPAT(SHSTK, "shstk", 0)
+X86_FEATURE_COMPAT(TBM, "tbm", 0)
+X86_FEATURE_COMPAT(TSXLDTRK, "tsxldtrk", 0)
+X86_FEATURE_COMPAT(VAES, "vaes", 0)
+X86_FEATURE_COMPAT(WAITPKG, "waitpkg", 0)
+X86_FEATURE_COMPAT(WBNOINVD, "wbnoinvd", 0)
+X86_FEATURE_COMPAT(XSAVE, "xsave", 0)
+X86_FEATURE_COMPAT(XSAVEC, "xsavec", 0)
+X86_FEATURE_COMPAT(XSAVEOPT, "xsaveopt", 0)
+X86_FEATURE_COMPAT(XSAVES, "xsaves", 0)
+X86_FEATURE_COMPAT(AMX_TILE, "amx-tile", 0)
+X86_FEATURE_COMPAT(AMX_INT8, "amx-int8", 0)
+X86_FEATURE_COMPAT(AMX_BF16, "amx-bf16", 0)
+X86_FEATURE_COMPAT(UINTR, "uintr", 0)
+X86_FEATURE_COMPAT(HRESET, "hreset", 0)
+X86_FEATURE_COMPAT(KL, "kl", 0)
+X86_FEATURE (FXSR, "fxsr")
+X86_FEATURE_COMPAT(WIDEKL, "widekl", 0)
+X86_FEATURE_COMPAT(AVXVNNI, "avxvnni", 0)
+X86_FEATURE_COMPAT(AVX512FP16, "avx512fp16", 0)
----------------
FreddyLeaf wrote:
gcc only set priority before `avx512f`: https://github.com/gcc-mirror/gcc/blob/9693459e030977d6e906ea7eb587ed09ee4fddbd/gcc/common/config/i386/i386-cpuinfo.h#L149
which means, they don't support ISAs to function multiversion features(_-attribute__((target())) and so on) after `avx512f`, see this example: https://godbolt.org/z/Ec96ex3cK
The reason why they didn't extend the priority feature list can be found in this thread: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89929
> As discussed in https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00416.html email thread, we reached the following consensus with H.J:
>
> - As any AVX512 extensions (apart from AVX512F) can be enabled individually, it's difficult to come up with priorities in dispatcher.
> - We don't have a syntax for target_clone attribute where one would say e.g. avx512f+avx512cd+avx512er.
> - So that we would reject these (AVX512* except AVX512F) in target_clone attribute and we recommend to use rather.
> target_clones(arch=skylake,arch=skylake-avx512,arch=cannonlake,arch=icelake-client,arch=icelake-server, ..)
> - Using that one can cover used AVX512 ISA combinations for existing CPUs
https://github.com/llvm/llvm-project/pull/79086
More information about the cfe-commits
mailing list