1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4
5 #include "avx512f-check.h"
6
7 static __m512d
8 __attribute__ ((noinline))
foo(double x,int i)9 foo (double x, int i)
10 {
11 switch (i)
12 {
13 case 7:
14 return _mm512_set_pd (x, 1, 1, 1, 1, 1, 1, 1);
15 case 6:
16 return _mm512_set_pd (1, x, 1, 1, 1, 1, 1, 1);
17 case 5:
18 return _mm512_set_pd (1, 1, x, 1, 1, 1, 1, 1);
19 case 4:
20 return _mm512_set_pd (1, 1, 1, x, 1, 1, 1, 1);
21 case 3:
22 return _mm512_set_pd (1, 1, 1, 1, x, 1, 1, 1);
23 case 2:
24 return _mm512_set_pd (1, 1, 1, 1, 1, x, 1, 1);
25 case 1:
26 return _mm512_set_pd (1, 1, 1, 1, 1, 1, x, 1);
27 case 0:
28 return _mm512_set_pd (1, 1, 1, 1, 1, 1, 1, x);
29 default:
30 abort ();
31 }
32 }
33
34 static __m512d
35 __attribute__ ((noinline))
foo_r(double x,int i)36 foo_r (double x, int i)
37 {
38 switch (i)
39 {
40 case 0:
41 return _mm512_setr_pd (x, 1, 1, 1, 1, 1, 1, 1);
42 case 1:
43 return _mm512_setr_pd (1, x, 1, 1, 1, 1, 1, 1);
44 case 2:
45 return _mm512_setr_pd (1, 1, x, 1, 1, 1, 1, 1);
46 case 3:
47 return _mm512_setr_pd (1, 1, 1, x, 1, 1, 1, 1);
48 case 4:
49 return _mm512_setr_pd (1, 1, 1, 1, x, 1, 1, 1);
50 case 5:
51 return _mm512_setr_pd (1, 1, 1, 1, 1, x, 1, 1);
52 case 6:
53 return _mm512_setr_pd (1, 1, 1, 1, 1, 1, x, 1);
54 case 7:
55 return _mm512_setr_pd (1, 1, 1, 1, 1, 1, 1, x);
56 default:
57 abort ();
58 }
59 }
60
61 static void
avx512f_test(void)62 avx512f_test (void)
63 {
64 double e = -3.234;
65 double v[8];
66 union512d res;
67 int i, j;
68
69 for (i = 0; i < 8; i++)
70 {
71 for (j = 0; j < 8; j++)
72 v[j] = 1;
73 v[i] = e;
74
75 res.x = foo (e, i);
76
77 if (check_union512d (res, v))
78 abort ();
79
80 res.x = _mm512_setzero_pd ();
81
82 res.x = foo_r (e, i);
83
84 if (check_union512d (res, v))
85 abort ();
86 }
87 }
88