Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ppc-fma-4.c
blob8372c36ae0d17f0cbe827ca0814f6fb58116d668
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. */
20 double
21 builtin_fma (double b, double c, double d)
23 return __builtin_fma (b, c, d); /* fmadd */
26 double
27 builtin_fms (double b, double c, double d)
29 return __builtin_fma (b, c, -d); /* fmsub */
32 double
33 builtin_fnma (double b, double c, double d)
35 return - __builtin_fma (b, c, d); /* fnmadd */
38 double
39 builtin_fnms (double b, double c, double d)
41 return - __builtin_fma (b, c, -d); /* fnmsub */
44 float
45 builtin_fmaf (float b, float c, float d)
47 return __builtin_fmaf (b, c, d); /* fmadds */
50 float
51 builtin_fmsf (float b, float c, float d)
53 return __builtin_fmaf (b, c, -d); /* fmsubs */
56 float
57 builtin_fnmaf (float b, float c, float d)
59 return - __builtin_fmaf (b, c, d); /* fnmadds */
62 float
63 builtin_fnmsf (float b, float c, float d)
65 return - __builtin_fmaf (b, c, -d); /* fnmsubs */
68 double
69 normal_fma (double b, double c, double d)
71 return (b * c) + d; /* fmul/fadd */
74 float
75 normal_fmaf (float b, float c, float d)
77 return (b * c) + d; /* fmuls/fadds */
80 #ifndef SIZE
81 #define SIZE 1024
82 #endif
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)));
89 void
90 vector_fmaf (void)
92 int i;
94 for (i = 0; i < SIZE; i++)
95 vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]); /* vaddfp */