1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-require-effective-target powerpc_altivec_ok } */
4 /* { dg-options "-O3 -ftree-vectorize -mcpu=power6 -maltivec -ffast-math" } */
5 /* { dg-final { scan-assembler-times "vmaddfp" 2 } } */
6 /* { dg-final { scan-assembler-times "fmadd " 2 } } */
7 /* { dg-final { scan-assembler-times "fmadds" 2 } } */
8 /* { dg-final { scan-assembler-times "fmsub " 1 } } */
9 /* { dg-final { scan-assembler-times "fmsubs" 1 } } */
10 /* { dg-final { scan-assembler-times "fnmadd " 1 } } */
11 /* { dg-final { scan-assembler-times "fnmadds" 1 } } */
12 /* { dg-final { scan-assembler-times "fnmsub " 1 } } */
13 /* { dg-final { scan-assembler-times "fnmsubs" 1 } } */
15 /* All functions should generate an appropriate (a * b) + c instruction
16 since -mfused-madd is on by default. */
19 builtin_fma (double b, double c, double d)
21 return __builtin_fma (b, c, d); /* fmadd */
25 builtin_fms (double b, double c, double d)
27 return __builtin_fma (b, c, -d); /* fmsub */
31 builtin_fnma (double b, double c, double d)
33 return - __builtin_fma (b, c, d); /* fnmadd */
37 builtin_fnms (double b, double c, double d)
39 return - __builtin_fma (b, c, -d); /* fnmsub */
43 builtin_fmaf (float b, float c, float d)
45 return __builtin_fmaf (b, c, d); /* fmadds */
49 builtin_fmsf (float b, float c, float d)
51 return __builtin_fmaf (b, c, -d); /* fmsubs */
55 builtin_fnmaf (float b, float c, float d)
57 return - __builtin_fmaf (b, c, d); /* fnmadds */
61 builtin_fnmsf (float b, float c, float d)
63 return - __builtin_fmaf (b, c, -d); /* fnmsubs */
67 normal_fma (double b, double c, double d)
69 return (b * c) + d; /* fmadd */
73 normal_fmaf (float b, float c, float d)
75 return (b * c) + d; /* fmadds */
82 float vfa[SIZE] __attribute__((__aligned__(32)));
83 float vfb[SIZE] __attribute__((__aligned__(32)));
84 float vfc[SIZE] __attribute__((__aligned__(32)));
85 float vfd[SIZE] __attribute__((__aligned__(32)));
92 for (i = 0; i < SIZE; i++)
93 vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]); /* vaddfp */
101 for (i = 0; i < SIZE; i++)
102 vfa[i] = (vfb[i] * vfc[i]) + vfd[i]; /* vaddfp */