Debian Codegraph @

gcc/testsuite/g++.target/i386/mv30.C

raw
1 // PR target/101696
2 // Test that dispatching can choose the right multiversion
3 // for x86-64 microarchitecture levels.
4
5 // { dg-do run }
6 // { dg-require-ifunc "" }
7 // { dg-options "-O2" }
8
9 #include <assert.h>
10
11 int __attribute__ ((target("default")))
12 foo ()
13 {
14 return 0;
15 }
16
17 int __attribute__ ((target("arch=x86-64"))) foo () {
18 return 1;
19 }
20
21 int __attribute__ ((target("arch=x86-64-v2"))) foo () {
22 return 2;
23 }
24
25 int __attribute__ ((target("arch=x86-64-v3"))) foo () {
26 return 3;
27 }
28
29 int __attribute__ ((target("arch=x86-64-v4"))) foo () {
30 return 4;
31 }
32
33
34 int main ()
35 {
36 int val = foo ();
37
38 if (__builtin_cpu_supports ("x86-64-v4"))
39 assert (val == 4);
40 else if (__builtin_cpu_supports ("x86-64-v3"))
41 assert (val == 3);
42 else if (__builtin_cpu_supports ("x86-64-v2"))
43 assert (val == 2);
44 else if (__builtin_cpu_supports ("x86-64"))
45 assert (val == 1);
46 else
47 assert (val == 0);
48
49 return 0;
50 }