https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115654
Bug ID: 115654 Summary: __builtin_cpu_supports should accept specific CPU names Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: alexhenrie24 at gmail dot com Target Milestone: --- I'd like to have a specific minimum supported CPU for some particular software, but also allow the software to run on newer CPUs that support a superset of the minimum CPU's features. For example, I could say that the compiled binary will run on an AMD Zen 3 processor or any other compatible processor, including any future Intel CPUs that support all of the Zen 3's features. If the software is run on an unsupported CPU, it needs to print a user-friendly error message. I can see two ways to do that: 1. Check for every possible CPU: __builtin_cpu_is("znver3") || __builtin_cpu_is("znver4") || __builtin_cpu_is("znver5"). This is tedious because I'd have to add to the list whenever new CPUs are added to GCC and it's easy to miss one. 2. Check for all of the required CPU features: __builtin_cpu_supports("x86-64-v3") && __builtin_cpu_supports("pclmul") && __builtin_cpu_supports("vpclmulqdq"). This is tedious because I have to look up all of the features that are enabled by -march=znver3 and it's easy to miss one. For my use case, it would be very helpful if I could just write __builtin_cpu_supports("znver3") to know, regardless of whether the CPU really _is_ a Zen 3, whether it is fully _compatible_ with a Zen 3.