Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx512f-vect-fmsubaddXXXps.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx512f } */
3 /* { dg-options "-O3 -mavx512f -mprefer-vector-width=512 -save-temps" } */
4
5 #include "fma-check.h"
6 void __attribute__((noipa))
7 check_fmaddsub (float * __restrict a, float *b, float *c, int n)
8 {
9 for (int i = 0; i < n; ++i)
10 {
11 a[16*i + 0] = b[16*i + 0] * c[16*i + 0] + a[16*i + 0];
12 a[16*i + 1] = b[16*i + 1] * c[16*i + 1] - a[16*i + 1];
13 a[16*i + 2] = b[16*i + 2] * c[16*i + 2] + a[16*i + 2];
14 a[16*i + 3] = b[16*i + 3] * c[16*i + 3] - a[16*i + 3];
15 a[16*i + 4] = b[16*i + 4] * c[16*i + 4] + a[16*i + 4];
16 a[16*i + 5] = b[16*i + 5] * c[16*i + 5] - a[16*i + 5];
17 a[16*i + 6] = b[16*i + 6] * c[16*i + 6] + a[16*i + 6];
18 a[16*i + 7] = b[16*i + 7] * c[16*i + 7] - a[16*i + 7];
19 a[16*i + 8] = b[16*i + 8] * c[16*i + 8] + a[16*i + 8];
20 a[16*i + 9] = b[16*i + 9] * c[16*i + 9] - a[16*i + 9];
21 a[16*i + 10] = b[16*i + 10] * c[16*i + 10] + a[16*i + 10];
22 a[16*i + 11] = b[16*i + 11] * c[16*i + 11] - a[16*i + 11];
23 a[16*i + 12] = b[16*i + 12] * c[16*i + 12] + a[16*i + 12];
24 a[16*i + 13] = b[16*i + 13] * c[16*i + 13] - a[16*i + 13];
25 a[16*i + 14] = b[16*i + 14] * c[16*i + 14] + a[16*i + 14];
26 a[16*i + 15] = b[16*i + 15] * c[16*i + 15] - a[16*i + 15];
27 }
28 }
29
30 static void
31 fma_test (void)
32 {
33 if (!__builtin_cpu_supports ("avx512f"))
34 return;
35 float a[16], b[16], c[16];
36 for (int i = 0; i < 16; ++i)
37 {
38 a[i] = i;
39 b[i] = 3*i;
40 c[i] = 7*i;
41 }
42 check_fmaddsub (a, b, c, 1);
43 const float d[16] = { 0., 20., 86., 186., 340., 520., 762., 1022.,
44 1352, 1692., 2110., 2530., 3036., 3536., 4130., 4710.};
45 for (int i = 0; i < 16; ++i)
46 if (a[i] != d[i])
47 __builtin_abort ();
48 }
49
50 /* { dg-final { scan-assembler {(?n)fmsubadd...ps[ \t].*%zmm[0-9]} } } */