[llvm-bugs] [Bug 41386] New: Function multi-versioning __attribute__((target("foo"))) doesn't support multiple values
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 4 15:31:48 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41386
Bug ID: 41386
Summary: Function multi-versioning
__attribute__((target("foo"))) doesn't support
multiple values
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: nheart at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 21732
--> https://bugs.llvm.org/attachment.cgi?id=21732&action=edit
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.
```
Attached a code sample that compiles on GCC.
Cheers,
Nick
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190404/9fdd5413/attachment.html>
More information about the llvm-bugs
mailing list