2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / fma-256-fmsubXX.c
blobd92aec0ec531f24432377147aeeb3993f9243fe0
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"
11 void
12 check_mm256_fmsub_pd (__m256d __A, __m256d __B, __m256d __C)
14 union256d a, b, c, e;
15 a.x = __A;
16 b.x = __B;
17 c.x = __C;
18 double d[4];
19 int i;
20 e.x = _mm256_fmsub_pd (__A, __B, __C);
21 for (i = 0; i < 4; i++)
23 d[i] = a.a[i] * b.a[i] - c.a[i];
25 if (check_union256d (e, d))
26 abort ();
29 void
30 check_mm256_fmsub_ps (__m256 __A, __m256 __B, __m256 __C)
32 union256 a, b, c, e;
33 a.x = __A;
34 b.x = __B;
35 c.x = __C;
36 float d[8];
37 int i;
38 e.x = _mm256_fmsub_ps (__A, __B, __C);
39 for (i = 0; i < 8; i++)
41 d[i] = a.a[i] * b.a[i] - c.a[i];
43 if (check_union256 (e, d))
44 abort ();
47 static void
48 fma_test (void)
50 union256 c[3];
51 union256d d[3];
52 int i, j;
53 for (i = 0; i < 3; i++)
55 for (j = 0; j < 8; j++)
56 c[i].a[j] = i * j + 3.5;
57 for (j = 0; j < 4; j++)
58 d[i].a[j] = i * j + 3.5;
60 check_mm256_fmsub_pd (d[0].x, d[1].x, d[2].x);
61 check_mm256_fmsub_ps (c[0].x, c[1].x, c[2].x);