https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83875
Bug ID: 83875 Summary: [feature request] target_clones compatible SIMD capability/length check Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: roland at rschulz dot eu Target Milestone: --- Currently there are two methods to check for SIMD capabilities (e.g. AVX). The preprocessor defines (e.g. __AVX__) and the builtin __builtin_cpu_supports. The problem is that neither can be used together with target_clones. One happens too early (preprocessor) and one too late (runtime). I suggest to add a builtin function which is constexpr and returns the CPU capabilities of the CPU target and otherwise works like the existing __builtin_cpu_supports. A possible name would be __builtin_target_supports. Even outside of target_clones function, such a builtin would have the advantage that it would allow replacing preprocessor #if with constexpr if. Prior to filing the feature request I asked on gcc-help for a solution: https://gcc.gnu.org/ml/gcc-help/2018-01/msg00057.html . No one had an idea for a solution with current capabilities, and one other developer voiced interest in such a feature.