1 /* Test case to check if Multiversioning works. */
2 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
3 /* { dg-require-ifunc "" } */
4 /* { dg-options "-O2 -fPIC" } */
9 int foo (); // Extra declaration that is merged with the second one.
10 int foo () __attribute__ ((target("default")));
11 /* The other versions of foo. Mix up the ordering and
12 check if the dispatching does it in the order of priority. */
13 /* Check combination of target attributes. */
14 int foo () __attribute__ ((target("arch=corei7,popcnt")));
15 /* The target operands in this declaration and the definition are re-ordered.
16 This should still work. */
17 int foo () __attribute__ ((target("ssse3,avx2")));
19 /* Check for all target attributes for which dispatchers are available. */
21 int foo () __attribute__((target("arch=core2")));
22 int foo () __attribute__((target("arch=corei7")));
23 int foo () __attribute__((target("arch=atom")));
25 int foo () __attribute__((target("avx")));
26 int foo () __attribute__ ((target("arch=core2,sse4.2")));
27 /* Check more arch=. */
28 int foo () __attribute__((target("arch=amdfam10")));
29 int foo () __attribute__((target("arch=bdver1")));
30 int foo () __attribute__((target("arch=bdver2")));
36 assert (val == (*p)());
38 /* Check in the exact same order in which the dispatching
39 is expected to happen. */
40 if (__builtin_cpu_is ("bdver1"))
42 else if (__builtin_cpu_is ("bdver2"))
44 else if (__builtin_cpu_supports ("avx2")
45 && __builtin_cpu_supports ("ssse3"))
47 else if (__builtin_cpu_supports ("avx"))
49 else if (__builtin_cpu_is ("corei7")
50 && __builtin_cpu_supports ("popcnt"))
52 else if (__builtin_cpu_is ("corei7"))
54 else if (__builtin_cpu_is ("amdfam10h"))
56 else if (__builtin_cpu_is ("core2")
57 && __builtin_cpu_supports ("sse4.2"))
59 else if (__builtin_cpu_is ("core2"))
61 else if (__builtin_cpu_is ("atom"))
69 int __attribute__ ((target("default")))
75 int __attribute__ ((target("arch=corei7,popcnt")))
80 int __attribute__ ((target("avx2,ssse3")))
86 int __attribute__ ((target("arch=core2")))
92 int __attribute__ ((target("arch=corei7")))
98 int __attribute__ ((target("arch=atom")))
104 int __attribute__ ((target("avx")))
110 int __attribute__ ((target("arch=core2,sse4.2")))
116 int __attribute__ ((target("arch=amdfam10")))
122 int __attribute__ ((target("arch=bdver1")))
128 int __attribute__ ((target("arch=bdver2")))