aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/sse2-extract-1.c
blob: f701cee8c02f7973fc8d40e323cc3b52e891302b (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* { dg-do run } */
/* { dg-options "-O2 -msse2" } */
/* { dg-require-effective-target sse2_runtime } */

extern void abort (void);
typedef unsigned long long uint64_t;

#define vector(elcount, type)  \
__attribute__((vector_size((elcount)*sizeof(type)))) type

#define FN(elcount, type, idx) \
__attribute__((noinline, noclone)) \
type f##type##elcount##_##idx (vector (elcount, type) x) { return x[idx] + 1; }
#define T2(elcount, type) \
  H (elcount, type) \
  F (elcount, type, 0) \
  F (elcount, type, 1)
#define T4(elcount, type) \
  T2 (elcount, type) \
  F (elcount, type, 2) \
  F (elcount, type, 3)
#define T8(elcount, type) \
  T4 (elcount, type) \
  F (elcount, type, 4) \
  F (elcount, type, 5) \
  F (elcount, type, 6) \
  F (elcount, type, 7)
#define T16(elcount, type) \
  T8 (elcount, type) \
  F (elcount, type, 8) \
  F (elcount, type, 9) \
  F (elcount, type, 10) \
  F (elcount, type, 11) \
  F (elcount, type, 12) \
  F (elcount, type, 13) \
  F (elcount, type, 14) \
  F (elcount, type, 15)
#define T32(elcount, type) \
  T16 (elcount, type) \
  F (elcount, type, 16) \
  F (elcount, type, 17) \
  F (elcount, type, 18) \
  F (elcount, type, 19) \
  F (elcount, type, 20) \
  F (elcount, type, 21) \
  F (elcount, type, 22) \
  F (elcount, type, 23) \
  F (elcount, type, 24) \
  F (elcount, type, 25) \
  F (elcount, type, 26) \
  F (elcount, type, 27) \
  F (elcount, type, 28) \
  F (elcount, type, 29) \
  F (elcount, type, 30) \
  F (elcount, type, 31)
#define TESTS_SSE2 \
T2 (2, double) E \
T2 (2, uint64_t) E \
T4 (4, float) E \
T4 (4, int) E \
T8 (8, short) E \
T16 (16, char) E
#define TESTS_AVX \
T4 (4, double) E \
T4 (4, uint64_t) E \
T8 (8, float) E \
T8 (8, int) E \
T16 (16, short) E \
T32 (32, char) E
#ifdef __AVX__
#define TESTS TESTS_SSE2 TESTS_AVX
#else
#define TESTS TESTS_SSE2
#endif

#define F FN
#define H(elcount, type)
#define E
TESTS

int
main ()
{
#undef F
#undef H
#undef E
#define H(elcount, type) \
  vector (elcount, type) v##type##elcount = {
#define E };
#define F(elcount, type, idx) idx + 1,
  TESTS
#undef F
#undef H
#undef E
#define H(elcount, type)
#define E
#define F(elcount, type, idx) \
  if (f##type##elcount##_##idx (v##type##elcount) != idx + 2) \
    abort ();
  TESTS
  return 0;
}