rs6000: Enable limited unrolling at -O2
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ppc-fma-3.c
blob8608116e2ee23e3fd1a66215a35821b2591a958e
1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_altivec_ok } */
4 /* { dg-require-effective-target powerpc_fprs } */
5 /* { dg-options "-O3 -ftree-vectorize -mdejagnu-cpu=power6 -maltivec -ffast-math -fno-unroll-loops" } */
6 /* { dg-final { scan-assembler-times "vmaddfp" 2 } } */
7 /* { dg-final { scan-assembler-times "fmadd " 2 } } */
8 /* { dg-final { scan-assembler-times "fmadds" 2 } } */
9 /* { dg-final { scan-assembler-times "fmsub " 1 } } */
10 /* { dg-final { scan-assembler-times "fmsubs" 1 } } */
11 /* { dg-final { scan-assembler-times "fnmadd " 1 } } */
12 /* { dg-final { scan-assembler-times "fnmadds" 1 } } */
13 /* { dg-final { scan-assembler-times "fnmsub " 1 } } */
14 /* { dg-final { scan-assembler-times "fnmsubs" 1 } } */
16 /* All functions should generate an appropriate (a * b) + c instruction
17 since -mfused-madd is on by default. */
19 double
20 builtin_fma (double b, double c, double d)
22 return __builtin_fma (b, c, d); /* fmadd */
25 double
26 builtin_fms (double b, double c, double d)
28 return __builtin_fma (b, c, -d); /* fmsub */
31 double
32 builtin_fnma (double b, double c, double d)
34 return - __builtin_fma (b, c, d); /* fnmadd */
37 double
38 builtin_fnms (double b, double c, double d)
40 return - __builtin_fma (b, c, -d); /* fnmsub */
43 float
44 builtin_fmaf (float b, float c, float d)
46 return __builtin_fmaf (b, c, d); /* fmadds */
49 float
50 builtin_fmsf (float b, float c, float d)
52 return __builtin_fmaf (b, c, -d); /* fmsubs */
55 float
56 builtin_fnmaf (float b, float c, float d)
58 return - __builtin_fmaf (b, c, d); /* fnmadds */
61 float
62 builtin_fnmsf (float b, float c, float d)
64 return - __builtin_fmaf (b, c, -d); /* fnmsubs */
67 double
68 normal_fma (double b, double c, double d)
70 return (b * c) + d; /* fmadd */
73 float
74 normal_fmaf (float b, float c, float d)
76 return (b * c) + d; /* fmadds */
79 #ifndef SIZE
80 #define SIZE 1024
81 #endif
83 float vfa[SIZE] __attribute__((__aligned__(32)));
84 float vfb[SIZE] __attribute__((__aligned__(32)));
85 float vfc[SIZE] __attribute__((__aligned__(32)));
86 float vfd[SIZE] __attribute__((__aligned__(32)));
88 void
89 vector_fmaf (void)
91 int i;
93 for (i = 0; i < SIZE; i++)
94 vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]); /* vaddfp */
97 void
98 vnormal_fmaf (void)
100 int i;
102 for (i = 0; i < SIZE; i++)
103 vfa[i] = (vfb[i] * vfc[i]) + vfd[i]; /* vaddfp */