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 -mcpu=power6 -maltivec -ffast-math" } */
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. */
20 builtin_fma (double b, double c, double d)
22 return __builtin_fma (b, c, d); /* fmadd */
26 builtin_fms (double b, double c, double d)
28 return __builtin_fma (b, c, -d); /* fmsub */
32 builtin_fnma (double b, double c, double d)
34 return - __builtin_fma (b, c, d); /* fnmadd */
38 builtin_fnms (double b, double c, double d)
40 return - __builtin_fma (b, c, -d); /* fnmsub */
44 builtin_fmaf (float b, float c, float d)
46 return __builtin_fmaf (b, c, d); /* fmadds */
50 builtin_fmsf (float b, float c, float d)
52 return __builtin_fmaf (b, c, -d); /* fmsubs */
56 builtin_fnmaf (float b, float c, float d)
58 return - __builtin_fmaf (b, c, d); /* fnmadds */
62 builtin_fnmsf (float b, float c, float d)
64 return - __builtin_fmaf (b, c, -d); /* fnmsubs */
68 normal_fma (double b, double c, double d)
70 return (b * c) + d; /* fmadd */
74 normal_fmaf (float b, float c, float d)
76 return (b * c) + d; /* fmadds */
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)));
93 for (i = 0; i < SIZE; i++)
94 vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]); /* vaddfp */
102 for (i = 0; i < SIZE; i++)
103 vfa[i] = (vfb[i] * vfc[i]) + vfd[i]; /* vaddfp */