| 1 |
/* { dg-do compile { target { powerpc*-*-* } } } */ |
| 2 |
/* { dg-skip-if "" { powerpc*-*-darwin* } } */ |
| 3 |
/* { dg-options "-O3 -ftree-vectorize -mdejagnu-cpu=power6 -maltivec -ffast-math -ffp-contract=off -fno-unroll-loops" } */ |
| 4 |
/* { dg-require-effective-target powerpc_altivec } */ |
| 5 |
/* { dg-require-effective-target powerpc_fprs } */ |
| 6 |
/* { dg-final { scan-assembler-times "vmaddfp" 1 } } */ |
| 7 |
/* { dg-final { scan-assembler-times "fmadd " 1 } } */ |
| 8 |
/* { dg-final { scan-assembler-times "fmadds" 1 } } */ |
| 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 } } */ |
| 15 |
|
| 16 |
/* Only the functions calling the builtin should generate an appropriate |
| 17 |
(a * b) + c instruction. */ |
| 18 |
|
| 19 |
double |
| 20 |
builtin_fma (double b, double c, double d) |
| 21 |
{ |
| 22 |
return __builtin_fma (b, c, d); /* fmadd */ |
| 23 |
} |
| 24 |
|
| 25 |
double |
| 26 |
builtin_fms (double b, double c, double d) |
| 27 |
{ |
| 28 |
return __builtin_fma (b, c, -d); /* fmsub */ |
| 29 |
} |
| 30 |
|
| 31 |
double |
| 32 |
builtin_fnma (double b, double c, double d) |
| 33 |
{ |
| 34 |
return - __builtin_fma (b, c, d); /* fnmadd */ |
| 35 |
} |
| 36 |
|
| 37 |
double |
| 38 |
builtin_fnms (double b, double c, double d) |
| 39 |
{ |
| 40 |
return - __builtin_fma (b, c, -d); /* fnmsub */ |
| 41 |
} |
| 42 |
|
| 43 |
float |
| 44 |
builtin_fmaf (float b, float c, float d) |
| 45 |
{ |
| 46 |
return __builtin_fmaf (b, c, d); /* fmadds */ |
| 47 |
} |
| 48 |
|
| 49 |
float |
| 50 |
builtin_fmsf (float b, float c, float d) |
| 51 |
{ |
| 52 |
return __builtin_fmaf (b, c, -d); /* fmsubs */ |
| 53 |
} |
| 54 |
|
| 55 |
float |
| 56 |
builtin_fnmaf (float b, float c, float d) |
| 57 |
{ |
| 58 |
return - __builtin_fmaf (b, c, d); /* fnmadds */ |
| 59 |
} |
| 60 |
|
| 61 |
float |
| 62 |
builtin_fnmsf (float b, float c, float d) |
| 63 |
{ |
| 64 |
return - __builtin_fmaf (b, c, -d); /* fnmsubs */ |
| 65 |
} |
| 66 |
|
| 67 |
double |
| 68 |
normal_fma (double b, double c, double d) |
| 69 |
{ |
| 70 |
return (b * c) + d; /* fmul/fadd */ |
| 71 |
} |
| 72 |
|
| 73 |
float |
| 74 |
normal_fmaf (float b, float c, float d) |
| 75 |
{ |
| 76 |
return (b * c) + d; /* fmuls/fadds */ |
| 77 |
} |
| 78 |
|
| 79 |
#ifndef SIZE |
| 80 |
#define SIZE 1024 |
| 81 |
#endif |
| 82 |
|
| 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))); |
| 87 |
|
| 88 |
void |
| 89 |
vector_fmaf (void) |
| 90 |
{ |
| 91 |
int i; |
| 92 |
|
| 93 |
for (i = 0; i < SIZE; i++) |
| 94 |
vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]); /* vaddfp */ |
| 95 |
} |