2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse3-movsldup.c
blob1ef2dd1b07f3eaefbfcc51eab88d5be4792c1b1b
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse3 } */
3 /* { dg-options "-O2 -msse3 -mfpmath=sse" } */
5 #ifndef CHECK_H
6 #define CHECK_H "sse3-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST sse3_test
11 #endif
13 #include CHECK_H
15 #include <pmmintrin.h>
17 static void
18 sse3_test_movsldup_reg (float *i1, float *r)
20 __m128 t1 = _mm_loadu_ps (i1);
21 __m128 t2 = _mm_moveldup_ps (t1);
23 _mm_storeu_ps (r, t2);
26 static void
27 sse3_test_movsldup_reg_subsume (float *i1, float *r)
29 __m128 t1 = _mm_load_ps (i1);
30 __m128 t2 = _mm_moveldup_ps (t1);
32 _mm_storeu_ps (r, t2);
35 static int
36 chk_ps (float *v1, float *v2)
38 int i;
39 int n_fails = 0;
41 for (i = 0; i < 4; i++)
42 if (v1[i] != v2[i])
43 n_fails += 1;
45 return n_fails;
48 static float p1[4] __attribute__ ((aligned(16)));
49 static float p2[4];
50 static float ck[4];
52 static float vals[80] =
54 100.0, 200.0, 300.0, 400.0, 5.0, -1.0, .345, -21.5,
55 1100.0, 0.235, 321.3, 53.40, 0.3, 10.0, 42.0, 32.52,
56 32.6, 123.3, 1.234, 2.156, 0.1, 3.25, 4.75, 32.44,
57 12.16, 52.34, 64.12, 71.13, -.1, 2.30, 5.12, 3.785,
58 541.3, 321.4, 231.4, 531.4, 71., 321., 231., -531.,
59 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45,
60 23.45, -1.43, -6.74, 6.345, -20.1, -20.1, -40.1, -40.1,
61 1.234, 2.345, 3.456, 4.567, 5.678, 6.789, 7.891, 8.912,
62 -9.32, -8.41, -7.50, -6.59, -5.68, -4.77, -3.86, -2.95,
63 9.32, 8.41, 7.50, 6.59, -5.68, -4.77, -3.86, -2.95
66 static void
67 TEST (void)
69 int i;
70 int fail = 0;
72 for (i = 0; i < 80; i += 2)
74 p1[0] = vals[i+0];
75 p1[1] = 0.0;
76 p1[2] = vals[i+1];
77 p1[3] = 1.0;
79 ck[0] = p1[0];
80 ck[1] = p1[0];
81 ck[2] = p1[2];
82 ck[3] = p1[2];
84 sse3_test_movsldup_reg (p1, p2);
86 fail += chk_ps (ck, p2);
88 sse3_test_movsldup_reg_subsume (p1, p2);
90 fail += chk_ps (ck, p2);
93 if (fail != 0)
94 abort ();