Stop only if there aren't any usable algorithms
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / fma-fmaddsubXX.c
blob89c816392f3ccf8860fd2cfaba027b9b1fc1ea33
1 /* { dg-do run } */
2 /* { dg-require-effective-target fma } */
3 /* { dg-options "-O2 -mfma" } */
5 #include "fma-check.h"
7 #include <x86intrin.h>
8 #include "m256-check.h"
10 void
11 check_mm_fmaddsub_ps (__m128 __A, __m128 __B, __m128 __C)
13 union128 a, b, c, e;
14 a.x = __A;
15 b.x = __B;
16 c.x = __C;
17 float d[4];
18 int i;
19 e.x = _mm_fmaddsub_ps (__A, __B, __C);
20 for (i = 0; i < 4; i++)
22 d[i] = a.a[i] * b.a[i] + (i % 2 == 1 ? c.a[i] : -c.a[i]);
24 if (check_union128 (e, d))
25 abort ();
28 void
29 check_mm_fmaddsub_pd (__m128d __A, __m128d __B, __m128d __C)
31 union128d a, b, c, e;
32 a.x = __A;
33 b.x = __B;
34 c.x = __C;
35 double d[2];
36 int i;
37 e.x = _mm_fmaddsub_pd (__A, __B, __C);
38 for (i = 0; i < 2; i++)
40 d[i] = a.a[i] * b.a[i] + (i % 2 == 1 ? c.a[i] : -c.a[i]);
42 if (check_union128d (e, d))
43 abort ();
46 static void
47 fma_test (void)
49 union128 a[3];
50 union128d b[3];
51 int i, j;
52 for (i = 0; i < 3; i++)
54 for (j = 0; j < 4; j++)
55 a[i].a[j] = i * j + 3.5;
56 for (j = 0; j < 2; j++)
57 b[i].a[j] = i * j + 3.5;
59 check_mm_fmaddsub_pd (b[0].x, b[1].x, b[2].x);
60 check_mm_fmaddsub_ps (a[0].x, a[1].x, a[2].x);