aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/ext/mv16.C
blob: 8992bfc6fc147ac442b02c057bfaf7d1a2f7ad44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Test that dispatching can choose the right multiversion
// for Intel CPUs with the same internal GCC processor id
// but slighly different sets of x86 extensions.

// { dg-do run { target i?86-*-* x86_64-*-* } }
// { dg-require-ifunc "" }
// { dg-options "-O2" }

#include <assert.h>

int __attribute__ ((target("default")))
foo ()
{
  return 0;
}

int __attribute__ ((target("arch=nehalem")))
foo ()
{
  return 4;
}

int __attribute__ ((target("arch=westmere")))
foo ()
{
  return 5;
}

int __attribute__ ((target("arch=sandybridge")))
foo ()
{
  return 8;
}

int __attribute__ ((target("arch=ivybridge")))
foo ()
{
  return 9;
}

int __attribute__ ((target("arch=haswell")))
foo ()
{
  return 12;
}

int main ()
{
  int val = foo ();

  if (__builtin_cpu_is ("nehalem"))
    assert (val == 4);
  else if (__builtin_cpu_is ("westmere"))
    assert (val == 5);
  else if (__builtin_cpu_is ("sandybridge"))
    assert (val == 8);
  else if (__builtin_cpu_is ("ivybridge"))
    assert (val == 9);
  else if (__builtin_cpu_is ("haswell"))
    assert (val == 12);
  else
    assert (val == 0);

  return 0;
}