Debian Codegraph @

gcc/testsuite/gcc.target/i386/cond_op_fma_double-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -march=skylake-avx512 -fdump-tree-optimized" } */
3 /* { dg-final { scan-tree-dump-times ".COND_FMA" 3 "optimized" } } */
4 /* { dg-final { scan-tree-dump-times ".COND_FNMA" 3 "optimized" } } */
5 /* { dg-final { scan-tree-dump-times ".COND_FMS" 3 "optimized" } } */
6 /* { dg-final { scan-tree-dump-times ".COND_FNMS" 3 "optimized" } } */
7 /* { dg-final { scan-assembler-times "vfmadd132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
8 /* { dg-final { scan-assembler-times "vfnmadd132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
9 /* { dg-final { scan-assembler-times "vfmsub132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
10 /* { dg-final { scan-assembler-times "vfnmsub132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
11 /* { dg-final { scan-assembler-times "vfmadd231pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
12 /* { dg-final { scan-assembler-times "vfnmadd231pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
13 /* { dg-final { scan-assembler-times "vfmsub231pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
14 /* { dg-final { scan-assembler-times "vfnmsub231pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
15 /* { dg-final { scan-assembler-times "vfmadd132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
16 /* { dg-final { scan-assembler-times "vfnmadd132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
17 /* { dg-final { scan-assembler-times "vfmsub132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
18 /* { dg-final { scan-assembler-times "vfnmsub132pd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
19
20 #ifndef NUM
21 #define NUM 800
22 #endif
23 #ifndef TYPE
24 #define TYPE double
25 #endif
26 #ifndef __BUILTIN_FMA
27 #define __BUILTIN_FMA __builtin_fma
28 #endif
29
30 TYPE a[NUM], b[NUM], c[NUM], d[NUM], e[NUM], j[NUM];
31 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
32 #define MAX(X,Y) ((X) < (Y) ? (Y) : (X))
33
34 #define FMA3(OPNAME, OP1, OP2) \
35 void \
36 __attribute__ ((noipa,optimize ("O3"))) \
37 foo3_##OPNAME () \
38 { \
39 for (int i = 0; i != NUM; i++) \
40 { \
41 TYPE tmp = MAX(d[i], e[i]); \
42 if (b[i] < c[i]) \
43 a[i] = __BUILTIN_FMA (OP1 d[i], e[i], OP2 tmp); \
44 else \
45 a[i] = tmp; \
46 } \
47 }
48
49 #define FMAZ(OPNAME, OP1, OP2) \
50 void \
51 __attribute__ ((noipa,optimize ("O3"))) \
52 fooz_##OPNAME () \
53 { \
54 for (int i = 0; i != NUM; i++) \
55 if (b[i] < c[i]) \
56 a[i] = __BUILTIN_FMA (OP1 d[i], e[i], OP2 a[i]); \
57 else \
58 a[i] = .0; \
59 }
60
61 #define FMA1(OPNAME, OP1, OP2) \
62 void \
63 __attribute__ ((noipa,optimize ("O3"))) \
64 foo1_##OPNAME () \
65 { \
66 for (int i = 0; i != NUM; i++) \
67 if (b[i] < c[i]) \
68 a[i] = __BUILTIN_FMA (OP1 d[i], e[i], OP2 a[i]); \
69 else \
70 a[i] = d[i]; \
71 }
72
73
74 FMAZ (fma,, +);
75 FMAZ (fms,, -);
76 FMAZ (fnma, -, +);
77 FMAZ (fnms, -, -);
78
79 FMA1 (fma,, +);
80 FMA1 (fms,, -);
81 FMA1 (fnma, -, +);
82 FMA1 (fnms, -, -);
83
84 FMA3 (fma,, +);
85 FMA3 (fms,, -);
86 FMA3 (fnma, -, +);
87 FMA3 (fnms, -, -);