[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / sse3-addsubps.c
blobb341ba8e74b5d15b4d40f683b5a58189b3d76c85
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mvsx -Wno-psabi" } */
3 /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */
4 /* { dg-require-effective-target p8vector_hw } */
6 #define NO_WARN_X86_INTRINSICS 1
7 #ifndef CHECK_H
8 #define CHECK_H "sse3-check.h"
9 #endif
11 #include CHECK_H
13 #ifndef TEST
14 #define TEST sse3_test_addsubps_1
15 #endif
17 #include <pmmintrin.h>
19 static void
20 sse3_test_addsubps (float *i1, float *i2, float *r)
22 __m128 t1 = _mm_loadu_ps (i1);
23 __m128 t2 = _mm_loadu_ps (i2);
25 t1 = _mm_addsub_ps (t1, t2);
27 _mm_storeu_ps (r, t1);
30 static void
31 sse3_test_addsubps_subsume (float *i1, float *i2, float *r)
33 __m128 t1 = _mm_load_ps (i1);
34 __m128 t2 = _mm_load_ps (i2);
36 t1 = _mm_addsub_ps (t1, t2);
38 _mm_storeu_ps (r, t1);
41 static int
42 chk_ps (float *v1, float *v2)
44 int i;
45 int n_fails = 0;
47 for (i = 0; i < 4; i++)
48 if (v1[i] != v2[i])
49 n_fails += 1;
51 return n_fails;
54 static float p1[4] __attribute__ ((aligned(16)));
55 static float p2[4] __attribute__ ((aligned(16)));
56 static float p3[4];
57 static float ck[4];
59 static float vals[] =
61 100.0, 200.0, 300.0, 400.0, 5.0, -1.0, .345, -21.5,
62 1100.0, 0.235, 321.3, 53.40, 0.3, 10.0, 42.0, 32.52,
63 32.6, 123.3, 1.234, 2.156, 0.1, 3.25, 4.75, 32.44,
64 12.16, 52.34, 64.12, 71.13, -.1, 2.30, 5.12, 3.785,
65 541.3, 321.4, 231.4, 531.4, 71., 321., 231., -531.,
66 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45,
67 23.45, -1.43, -6.74, 6.345, -20.1, -20.1, -40.1, -40.1,
68 1.234, 2.345, 3.456, 4.567, 5.678, 6.789, 7.891, 8.912,
69 -9.32, -8.41, -7.50, -6.59, -5.68, -4.77, -3.86, -2.95,
70 9.32, 8.41, 7.50, 6.59, -5.68, -4.77, -3.86, -2.95
73 //static
74 void
75 TEST (void)
77 int i;
78 int fail = 0;
80 for (i = 0; i < sizeof (vals) / sizeof (vals); i += 8)
82 p1[0] = vals[i+0];
83 p1[1] = vals[i+1];
84 p1[2] = vals[i+2];
85 p1[3] = vals[i+3];
87 p2[0] = vals[i+4];
88 p2[1] = vals[i+5];
89 p2[2] = vals[i+6];
90 p2[3] = vals[i+7];
92 ck[0] = p1[0] - p2[0];
93 ck[1] = p1[1] + p2[1];
94 ck[2] = p1[2] - p2[2];
95 ck[3] = p1[3] + p2[3];
97 sse3_test_addsubps (p1, p2, p3);
99 fail += chk_ps (ck, p3);
101 sse3_test_addsubps_subsume (p1, p2, p3);
103 fail += chk_ps (ck, p3);
106 if (fail != 0)
107 abort ();