PR c++/85553
[official-gcc.git] / gcc / testsuite / g++.dg / ext / mv16.C
blob3e7c228a7f13b4ebcb88d48973ec598bc06c8d97
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.
5 // { dg-do run { target i?86-*-* x86_64-*-* } }
6 // { dg-require-ifunc "" }
7 // { dg-options "-O2" }
9 #include <assert.h>
11 int __attribute__ ((target("default")))
12 foo ()
14   return 0;
17 int __attribute__ ((target("arch=nehalem")))
18 foo ()
20   return 4;
23 int __attribute__ ((target("arch=westmere")))
24 foo ()
26   return 5;
29 int __attribute__ ((target("arch=sandybridge")))
30 foo ()
32   return 8;
35 int __attribute__ ((target("arch=ivybridge")))
36 foo ()
38   return 9;
41 int __attribute__ ((target("arch=haswell")))
42 foo ()
44   return 12;
47 int __attribute__ ((target("arch=broadwell"))) foo () {
48   return 13;
51 int __attribute__ ((target("arch=skylake"))) foo () {
52   return 14;
55 int __attribute__ ((target("arch=skylake-avx512"))) foo () {
56   return 15;
59 int __attribute__ ((target("arch=cannonlake"))) foo () {
60   return 16;
63 int __attribute__ ((target("arch=icelake-client"))) foo () {
64   return 17;
67 int __attribute__ ((target("arch=icelake-server"))) foo () {
68   return 18;
71 int main ()
73   int val = foo ();
75   if (__builtin_cpu_is ("nehalem"))
76     assert (val == 4);
77   else if (__builtin_cpu_is ("westmere"))
78     assert (val == 5);
79   else if (__builtin_cpu_is ("sandybridge"))
80     assert (val == 8);
81   else if (__builtin_cpu_is ("ivybridge"))
82     assert (val == 9);
83   else if (__builtin_cpu_is ("haswell"))
84     assert (val == 12);
85   else if (__builtin_cpu_is ("broadwell"))
86     assert (val == 13);
87   else if (__builtin_cpu_is ("skylake"))
88     assert (val == 14);
89   else if (__builtin_cpu_is ("skylake-avx512"))
90     assert (val == 15);
91   else if (__builtin_cpu_is ("cannonlake"))
92     assert (val == 16);
93   else if (__builtin_cpu_is ("icelake-client"))
94     assert (val == 17);
95   else if (__builtin_cpu_is ("icelake-server"))
96     assert (val == 18);
97   else
98     assert (val == 0);
100   return 0;