Created attachment 21732
Example function multi-versioning
Hey,
I am not sure if this is the correct place for this report. It is a mild enhancement/feature request.
Function multi-versioning was introduced recently in clang and seems to work quite well. However GCC allows for multiple targets to be specified in a single function definition, so that if you have some code that captures AVX and AVX2 you don't have to write two different functions for two different architectures if the codepath is the same. You can do:
attribute((target("avx2", "avx512f"))) int foo(int i) {
return 1;
}
Or
attribute((target("sse4.2"), target("avx"))) int foo(int i) {
return 3;
}
(The latter version compiles, but I'm not sure if it produces the correct result).
Currently these do not compile on clang resulting in the following error:
test.cpp:7:16: error: 'target' attribute takes one argument
attribute((target("sse2", "ssse3"))) int foo(int i) {
Could we have something akin to the first option in Clang? Reference to the relevant GCC documentation bit:
Multiple target back ends implement the target attribute to specify that a function is to be compiled with different target options than specified on the command line. One or more strings can be provided as arguments. Each string consists of one or more comma-separated suffixes to the -m prefix jointly forming the name of a machine-dependent option. See Machine-Dependent Options.
test.cpp
(453 bytes, text/x-c++src)test.cpp
(504 bytes, text/x-c++src)Created attachment 21732 Example function multi-versioning
Hey,
I am not sure if this is the correct place for this report. It is a mild enhancement/feature request.
Function multi-versioning was introduced recently in clang and seems to work quite well. However GCC allows for multiple targets to be specified in a single function definition, so that if you have some code that captures AVX and AVX2 you don't have to write two different functions for two different architectures if the codepath is the same. You can do:
attribute((target("avx2", "avx512f"))) int foo(int i) { return 1; }
Or
attribute((target("sse4.2"), target("avx"))) int foo(int i) { return 3; }
(The latter version compiles, but I'm not sure if it produces the correct result).
Currently these do not compile on clang resulting in the following error:
test.cpp:7:16: error: 'target' attribute takes one argument attribute((target("sse2", "ssse3"))) int foo(int i) {
Could we have something akin to the first option in Clang? Reference to the relevant GCC documentation bit:
Attached a code sample that compiles on GCC.
Cheers,
Nick