Debian Codegraph @

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

raw
1 // Test that dispatching can choose the right multiversion
2 // for Intel CPUs with the same internal GCC processor id
3 // but slighly different sets of x86 extensions.
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=nehalem")))
18 foo ()
19 {
20 return 4;
21 }
22
23 int __attribute__ ((target("arch=westmere")))
24 foo ()
25 {
26 return 5;
27 }
28
29 int __attribute__ ((target("arch=sandybridge")))
30 foo ()
31 {
32 return 8;
33 }
34
35 int __attribute__ ((target("arch=ivybridge")))
36 foo ()
37 {
38 return 9;
39 }
40
41 int __attribute__ ((target("arch=haswell")))
42 foo ()
43 {
44 return 12;
45 }
46
47 int __attribute__ ((target("arch=broadwell"))) foo () {
48 return 13;
49 }
50
51 int __attribute__ ((target("arch=skylake"))) foo () {
52 return 14;
53 }
54
55 int __attribute__ ((target("arch=skylake-avx512"))) foo () {
56 return 15;
57 }
58
59 int __attribute__ ((target("arch=cannonlake"))) foo () {
60 return 16;
61 }
62
63 int __attribute__ ((target("arch=icelake-client"))) foo () {
64 return 17;
65 }
66
67 int __attribute__ ((target("arch=icelake-server"))) foo () {
68 return 18;
69 }
70
71 int __attribute__ ((target("arch=cascadelake"))) foo () {
72 return 19;
73 }
74
75 int __attribute__ ((target("arch=tigerlake"))) foo () {
76 return 20;
77 }
78
79 int __attribute__ ((target("arch=cooperlake"))) foo () {
80 return 21;
81 }
82
83 int __attribute__ ((target("arch=sapphirerapids"))) foo () {
84 return 22;
85 }
86
87 int __attribute__ ((target("arch=alderlake"))) foo () {
88 return 23;
89 }
90
91 int __attribute__ ((target("arch=rocketlake"))) foo () {
92 return 24;
93 }
94
95 int __attribute__ ((target("arch=sierraforest"))) foo () {
96 return 25;
97 }
98
99 int __attribute__ ((target("arch=graniterapids"))) foo () {
100 return 26;
101 }
102
103 int __attribute__ ((target("arch=grandridge"))) foo () {
104 return 27;
105 }
106
107 int __attribute__ ((target("arch=graniterapids-d"))) foo () {
108 return 28;
109 }
110
111 int __attribute__ ((target("arch=arrowlake"))) foo () {
112 return 29;
113 }
114
115 int __attribute__ ((target("arch=arrowlake-s"))) foo () {
116 return 30;
117 }
118
119 int __attribute__ ((target("arch=clearwaterforest"))) foo () {
120 return 31;
121 }
122
123 int __attribute__ ((target("arch=pantherlake"))) foo () {
124 return 32;
125 }
126
127 int __attribute__ ((target("arch=diamondrapids"))) foo () {
128 return 33;
129 }
130
131 int main ()
132 {
133 int val = foo ();
134
135 if (__builtin_cpu_is ("nehalem"))
136 assert (val == 4);
137 else if (__builtin_cpu_is ("westmere"))
138 assert (val == 5);
139 else if (__builtin_cpu_is ("sandybridge"))
140 assert (val == 8);
141 else if (__builtin_cpu_is ("ivybridge"))
142 assert (val == 9);
143 else if (__builtin_cpu_is ("haswell"))
144 assert (val == 12);
145 else if (__builtin_cpu_is ("broadwell"))
146 assert (val == 13);
147 else if (__builtin_cpu_is ("skylake"))
148 assert (val == 14);
149 else if (__builtin_cpu_is ("skylake-avx512"))
150 assert (val == 15);
151 else if (__builtin_cpu_is ("cannonlake"))
152 assert (val == 16);
153 else if (__builtin_cpu_is ("icelake-client"))
154 assert (val == 17);
155 else if (__builtin_cpu_is ("icelake-server"))
156 assert (val == 18);
157 else if (__builtin_cpu_is ("cascadelake"))
158 assert (val == 19);
159 else if (__builtin_cpu_is ("tigerlake"))
160 assert (val == 20);
161 else if (__builtin_cpu_is ("cooperlake"))
162 assert (val == 21);
163 else if (__builtin_cpu_is ("sapphirerapids"))
164 assert (val == 22);
165 else if (__builtin_cpu_is ("alderlake"))
166 assert (val == 23);
167 else if (__builtin_cpu_is ("rocketlake"))
168 assert (val == 24);
169 else if (__builtin_cpu_is ("sierraforest"))
170 assert (val == 25);
171 else if (__builtin_cpu_is ("graniterapids"))
172 assert (val == 26);
173 else if (__builtin_cpu_is ("grandridge"))
174 assert (val == 27);
175 else if (__builtin_cpu_is ("graniterapids-d"))
176 assert (val == 28);
177 else if (__builtin_cpu_is ("arrowlake"))
178 assert (val == 29);
179 else if (__builtin_cpu_is ("arrowlake-s"))
180 assert (val == 30);
181 else if (__builtin_cpu_is ("clearwaterforest"))
182 assert (val == 31);
183 else if (__builtin_cpu_is ("pantherlake"))
184 assert (val == 32);
185 else if (__builtin_cpu_is ("diamondrapids"))
186 assert (val == 33);
187 else
188 assert (val == 0);
189
190 return 0;
191 }