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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to