[Disclaimer: I sent this to gcc-help two weeks ago, but didn't get an answer. Maybe the topic is more suited for the main gcc list ... I really think the feature in question would be extremely useful to have, and easy to add!]
Hi, I'm currently writing an FFT library which tries to make use of SIMD instructions and uses a lot of variables with __attribute__ ((vector_size (xyz)) The resulting source is nicely portable and architecture-independent - except for the one place where I need to determine the maximum hardware-supported vector length on the target CPU. This currently looks like #if defined(__AVX__) constexpr int veclen=32; #elif defined(__SSE2__) constexpr int veclen=16; [...] This approach requires me to add an #ifdef for many architectures, most of which I cannot really test on ... and new architectures will be unsupported by default. Hence my question: is there a way in gcc to determine the hardware vector length for the architecture the compiler is currently targeting? Some predefined macro like HARDWARE_VECTOR_LENGTH_IN_BYTES which is 32 for AVX, 16 for SSE2, and has proper values for Neon, VPX etc. etc. If this is not provided at the moment, would it bo possible to add this in the future? This could massively simplify writing and maintaining multi-platform SIMD code. Thanks, Martin