2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx-set-v16hi-4.c
bloba707fc8dced61956b8c4776b7fcde75d146f3973
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx } */
3 /* { dg-options "-O2 -mavx" } */
5 #include "avx-check.h"
7 static __m256i
8 __attribute__((noinline))
9 foo (short x, int i)
11 switch (i)
13 case 15:
14 return _mm256_set_epi16 (x, 0, 0, 0, 0, 0, 0, 0,
15 0, 0, 0, 0, 0, 0, 0, 0);
16 case 14:
17 return _mm256_set_epi16 (0, x, 0, 0, 0, 0, 0, 0,
18 0, 0, 0, 0, 0, 0, 0, 0);
19 case 13:
20 return _mm256_set_epi16 (0, 0, x, 0, 0, 0, 0, 0,
21 0, 0, 0, 0, 0, 0, 0, 0);
22 case 12:
23 return _mm256_set_epi16 (0, 0, 0, x, 0, 0, 0, 0,
24 0, 0, 0, 0, 0, 0, 0, 0);
25 case 11:
26 return _mm256_set_epi16 (0, 0, 0, 0, x, 0, 0, 0,
27 0, 0, 0, 0, 0, 0, 0, 0);
28 case 10:
29 return _mm256_set_epi16 (0, 0, 0, 0, 0, x, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0);
31 case 9:
32 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, x, 0,
33 0, 0, 0, 0, 0, 0, 0, 0);
34 case 8:
35 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, x,
36 0, 0, 0, 0, 0, 0, 0, 0);
37 case 7:
38 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
39 x, 0, 0, 0, 0, 0, 0, 0);
40 case 6:
41 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
42 0, x, 0, 0, 0, 0, 0, 0);
43 case 5:
44 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, x, 0, 0, 0, 0, 0);
46 case 4:
47 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, x, 0, 0, 0, 0);
49 case 3:
50 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, x, 0, 0, 0);
52 case 2:
53 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, x, 0, 0);
55 case 1:
56 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, x, 0);
58 case 0:
59 return _mm256_set_epi16 (0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, x);
61 default:
62 abort ();
66 static void
67 avx_test (void)
69 short e = 0xbeef;
70 short v[16];
71 union256i_w u;
72 int i, j;
74 for (i = 0; i < ARRAY_SIZE (v); i++)
76 for (j = 0; j < ARRAY_SIZE (v); j++)
77 v[j] = 0;
78 v[i] = e;
79 u.x = foo (e, i);
80 if (check_union256i_w (u, v))
81 abort ();