1 /* { dg-do run } */
2 /* { dg-options "-O3 -mpower8-vector -Wno-psabi" } */
3 /* { dg-require-effective-target p8vector_hw } */
4
5 #ifndef CHECK_H
6 #define CHECK_H "sse3-check.h"
7 #endif
8 #include CHECK_H
9
10 #ifndef TEST
11 #define TEST sse3_test_movddup_1
12 #endif
13
14 #define NO_WARN_X86_INTRINSICS 1
15 #include <pmmintrin.h>
16
17 static void
sse3_test_movddup_mem(double * i1,double * r)18 sse3_test_movddup_mem (double *i1, double *r)
19 {
20 __m128d t1 = _mm_loaddup_pd (i1);
21
22 _mm_storeu_pd (r, t1);
23 }
24
25 static double cnst1 [2] = {1.0, 1.0};
26
27 static void
sse3_test_movddup_reg(double * i1,double * r)28 sse3_test_movddup_reg (double *i1, double *r)
29 {
30 __m128d t1 = _mm_loadu_pd (i1);
31 __m128d t2 = _mm_loadu_pd (&cnst1[0]);
32
33 t1 = _mm_mul_pd (t1, t2);
34 t2 = _mm_movedup_pd (t1);
35
36 _mm_storeu_pd (r, t2);
37 }
38
39 static void
sse3_test_movddup_reg_subsume_unaligned(double * i1,double * r)40 sse3_test_movddup_reg_subsume_unaligned (double *i1, double *r)
41 {
42 __m128d t1 = _mm_loadu_pd (i1);
43 __m128d t2 = _mm_movedup_pd (t1);
44
45 _mm_storeu_pd (r, t2);
46 }
47
48 static void
sse3_test_movddup_reg_subsume_ldsd(double * i1,double * r)49 sse3_test_movddup_reg_subsume_ldsd (double *i1, double *r)
50 {
51 __m128d t1 = _mm_load_sd (i1);
52 __m128d t2 = _mm_movedup_pd (t1);
53
54 _mm_storeu_pd (r, t2);
55 }
56
57 static void
sse3_test_movddup_reg_subsume(double * i1,double * r)58 sse3_test_movddup_reg_subsume (double *i1, double *r)
59 {
60 __m128d t1 = _mm_load_pd (i1);
61 __m128d t2 = _mm_movedup_pd (t1);
62
63 _mm_storeu_pd (r, t2);
64 }
65
66 static int
chk_pd(double * v1,double * v2)67 chk_pd (double *v1, double *v2)
68 {
69 int i;
70 int n_fails = 0;
71
72 for (i = 0; i < 2; i++)
73 if (v1[i] != v2[i])
74 n_fails += 1;
75
76 return n_fails;
77 }
78
79 static double p1[2] __attribute__ ((aligned(16)));
80 static double p2[2];
81 static double ck[2];
82
83 static double vals[] =
84 {
85 100.0, 200.0, 300.0, 400.0, 5.0, -1.0, .345, -21.5,
86 1100.0, 0.235, 321.3, 53.40, 0.3, 10.0, 42.0, 32.52,
87 32.6, 123.3, 1.234, 2.156, 0.1, 3.25, 4.75, 32.44,
88 12.16, 52.34, 64.12, 71.13, -.1, 2.30, 5.12, 3.785,
89 541.3, 321.4, 231.4, 531.4, 71., 321., 231., -531.,
90 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45,
91 23.45, -1.43, -6.74, 6.345, -20.1, -20.1, -40.1, -40.1,
92 1.234, 2.345, 3.456, 4.567, 5.678, 6.789, 7.891, 8.912,
93 -9.32, -8.41, -7.50, -6.59, -5.68, -4.77, -3.86, -2.95,
94 9.32, 8.41, 7.50, 6.59, -5.68, -4.77, -3.86, -2.95
95 };
96
97 //static
98 void
TEST(void)99 TEST (void)
100 {
101 int i;
102 int fail = 0;
103
104 for (i = 0; i < sizeof (vals) / sizeof (vals[0]); i += 1)
105 {
106 p1[0] = vals[i+0];
107
108 ck[0] = p1[0];
109 ck[1] = p1[0];
110
111 sse3_test_movddup_mem (p1, p2);
112
113 fail += chk_pd (ck, p2);
114
115 sse3_test_movddup_reg (p1, p2);
116
117 fail += chk_pd (ck, p2);
118
119 sse3_test_movddup_reg_subsume (p1, p2);
120
121 fail += chk_pd (ck, p2);
122
123 sse3_test_movddup_reg_subsume_unaligned (p1, p2);
124
125 fail += chk_pd (ck, p2);
126
127 sse3_test_movddup_reg_subsume_ldsd (p1, p2);
128
129 fail += chk_pd (ck, p2);
130 }
131
132 if (fail != 0)
133 abort ();
134 }
135