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-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */
6 /* { dg-options "-O3 -ftree-vectorize -mcpu=power6 -maltivec -ffast-math -ffp-contract=off" } */
7 /* { dg-final { scan-assembler-times "vmaddfp" 1 } } */
8 /* { dg-final { scan-assembler-times "fmadd " 1 } } */
9 /* { dg-final { scan-assembler-times "fmadds" 1 } } */
10 /* { dg-final { scan-assembler-times "fmsub " 1 } } */
11 /* { dg-final { scan-assembler-times "fmsubs" 1 } } */
12 /* { dg-final { scan-assembler-times "fnmadd " 1 } } */
13 /* { dg-final { scan-assembler-times "fnmadds" 1 } } */
14 /* { dg-final { scan-assembler-times "fnmsub " 1 } } */
15 /* { dg-final { scan-assembler-times "fnmsubs" 1 } } */
17 /* Only the functions calling the builtin should generate an appropriate
18 (a * b) + c instruction. */
21 builtin_fma (double b
, double c
, double d
)
23 return __builtin_fma (b
, c
, d
); /* fmadd */
27 builtin_fms (double b
, double c
, double d
)
29 return __builtin_fma (b
, c
, -d
); /* fmsub */
33 builtin_fnma (double b
, double c
, double d
)
35 return - __builtin_fma (b
, c
, d
); /* fnmadd */
39 builtin_fnms (double b
, double c
, double d
)
41 return - __builtin_fma (b
, c
, -d
); /* fnmsub */
45 builtin_fmaf (float b
, float c
, float d
)
47 return __builtin_fmaf (b
, c
, d
); /* fmadds */
51 builtin_fmsf (float b
, float c
, float d
)
53 return __builtin_fmaf (b
, c
, -d
); /* fmsubs */
57 builtin_fnmaf (float b
, float c
, float d
)
59 return - __builtin_fmaf (b
, c
, d
); /* fnmadds */
63 builtin_fnmsf (float b
, float c
, float d
)
65 return - __builtin_fmaf (b
, c
, -d
); /* fnmsubs */
69 normal_fma (double b
, double c
, double d
)
71 return (b
* c
) + d
; /* fmul/fadd */
75 normal_fmaf (float b
, float c
, float d
)
77 return (b
* c
) + d
; /* fmuls/fadds */
84 float vfa
[SIZE
] __attribute__((__aligned__(32)));
85 float vfb
[SIZE
] __attribute__((__aligned__(32)));
86 float vfc
[SIZE
] __attribute__((__aligned__(32)));
87 float vfd
[SIZE
] __attribute__((__aligned__(32)));
94 for (i
= 0; i
< SIZE
; i
++)
95 vfa
[i
] = __builtin_fmaf (vfb
[i
], vfc
[i
], vfd
[i
]); /* vaddfp */