1 /* { dg-do run } */
2 /* { dg-require-effective-target fma } */
3 /* { dg-options "-O2 -mfma" } */
4 
5 #include "fma-check.h"
6 
7 #include <x86intrin.h>
8 #include "m256-check.h"
9 
10 
11 void
check_mm256_fmsub_pd(__m256d __A,__m256d __B,__m256d __C)12 check_mm256_fmsub_pd (__m256d __A, __m256d __B, __m256d __C)
13 {
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++)
22     {
23       d[i] = a.a[i] * b.a[i] - c.a[i];
24     }
25   if (check_union256d (e, d))
26     abort ();
27 }
28 
29 void
check_mm256_fmsub_ps(__m256 __A,__m256 __B,__m256 __C)30 check_mm256_fmsub_ps (__m256 __A, __m256 __B, __m256 __C)
31 {
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++)
40     {
41       d[i] = a.a[i] * b.a[i] - c.a[i];
42     }
43   if (check_union256 (e, d))
44     abort ();
45 }
46 
47 static void
fma_test(void)48 fma_test (void)
49 {
50   union256 c[3];
51   union256d d[3];
52   int i, j;
53   for (i = 0; i < 3; i++)
54     {
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;
59     }
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);
62 }
63