| 1 |
/* { dg-do compile { target { powerpc*-*-* } } } */ |
| 2 |
/* { dg-skip-if "" { powerpc*-*-darwin* } } */ |
| 3 |
/* { dg-options "-O3 -ftree-vectorize -mrecip=all -ffast-math -mdejagnu-cpu=power7 -fno-unroll-loops" } */ |
| 4 |
/* { dg-require-effective-target powerpc_vsx } */ |
| 5 |
/* { dg-final { scan-assembler-times "xvredp" 4 } } */ |
| 6 |
/* { dg-final { scan-assembler-times "xvresp" 5 } } */ |
| 7 |
/* { dg-final { scan-assembler-times "xsredp\|fre\ " 2 } } */ |
| 8 |
/* { dg-final { scan-assembler-times "fres\|xsresp" 2 } } */ |
| 9 |
/* { dg-final { scan-assembler-times "fmuls\|xsmulsp" 2 } } */ |
| 10 |
/* { dg-final { scan-assembler-times "fnmsubs\|xsnmsub.sp" 2 } } */ |
| 11 |
/* { dg-final { scan-assembler-times "xsmuldp\|fmul\ " 2 } } */ |
| 12 |
/* { dg-final { scan-assembler-times "xsnmsub.dp\|fnmsub\ " 4 } } */ |
| 13 |
/* { dg-final { scan-assembler-times "xvmulsp" 7 } } */ |
| 14 |
/* { dg-final { scan-assembler-times "xvnmsub.sp" 5 } } */ |
| 15 |
/* { dg-final { scan-assembler-times "xvmuldp" 6 } } */ |
| 16 |
/* { dg-final { scan-assembler-times "xvnmsub.dp" 8 } } */ |
| 17 |
|
| 18 |
#include <altivec.h> |
| 19 |
|
| 20 |
float f_recip (float a, float b) { return __builtin_recipdivf (a, b); } |
| 21 |
double d_recip (double a, double b) { return __builtin_recipdiv (a, b); } |
| 22 |
|
| 23 |
float f_div (float a, float b) { return a / b; } |
| 24 |
double d_div (double a, double b) { return a / b; } |
| 25 |
|
| 26 |
#define SIZE 1024 |
| 27 |
|
| 28 |
double d_a[SIZE] __attribute__((__aligned__(32))); |
| 29 |
double d_b[SIZE] __attribute__((__aligned__(32))); |
| 30 |
double d_c[SIZE] __attribute__((__aligned__(32))); |
| 31 |
|
| 32 |
float f_a[SIZE] __attribute__((__aligned__(32))); |
| 33 |
float f_b[SIZE] __attribute__((__aligned__(32))); |
| 34 |
float f_c[SIZE] __attribute__((__aligned__(32))); |
| 35 |
|
| 36 |
void vec_f_recip (void) |
| 37 |
{ |
| 38 |
int i; |
| 39 |
|
| 40 |
for (i = 0; i < SIZE; i++) |
| 41 |
f_a[i] = __builtin_recipdivf (f_b[i], f_c[i]); |
| 42 |
} |
| 43 |
|
| 44 |
void vec_d_recip (void) |
| 45 |
{ |
| 46 |
int i; |
| 47 |
|
| 48 |
for (i = 0; i < SIZE; i++) |
| 49 |
d_a[i] = __builtin_recipdiv (d_b[i], d_c[i]); |
| 50 |
} |
| 51 |
|
| 52 |
void vec_f_div (void) |
| 53 |
{ |
| 54 |
int i; |
| 55 |
|
| 56 |
for (i = 0; i < SIZE; i++) |
| 57 |
f_a[i] = f_b[i] / f_c[i]; |
| 58 |
} |
| 59 |
|
| 60 |
void vec_f_div2 (void) |
| 61 |
{ |
| 62 |
int i; |
| 63 |
|
| 64 |
for (i = 0; i < SIZE; i++) |
| 65 |
f_a[i] = f_b[i] / 2.0f; |
| 66 |
} |
| 67 |
|
| 68 |
void vec_f_div53 (void) |
| 69 |
{ |
| 70 |
int i; |
| 71 |
|
| 72 |
for (i = 0; i < SIZE; i++) |
| 73 |
f_a[i] = f_b[i] / 53.0f; |
| 74 |
} |
| 75 |
|
| 76 |
void vec_d_div (void) |
| 77 |
{ |
| 78 |
int i; |
| 79 |
|
| 80 |
for (i = 0; i < SIZE; i++) |
| 81 |
d_a[i] = d_b[i] / d_c[i]; |
| 82 |
} |
| 83 |
|
| 84 |
void vec_d_div2 (void) |
| 85 |
{ |
| 86 |
int i; |
| 87 |
|
| 88 |
for (i = 0; i < SIZE; i++) |
| 89 |
d_a[i] = d_b[i] / 2.0; |
| 90 |
} |
| 91 |
|
| 92 |
void vec_d_div53 (void) |
| 93 |
{ |
| 94 |
int i; |
| 95 |
|
| 96 |
for (i = 0; i < SIZE; i++) |
| 97 |
d_a[i] = d_b[i] / 53.0; |
| 98 |
} |
| 99 |
|
| 100 |
vector float v4sf_recip1 (vector float a, vector float b) { return vec_recipdiv (a, b); } |
| 101 |
vector float v4sf_recip2 (vector float a, vector float b) { return __builtin_altivec_vrecipdivfp (a, b); } |
| 102 |
vector double v2df_recip1 (vector double a, vector double b) { return vec_recipdiv (a, b); } |
| 103 |
vector float v4sf_recip3 (vector float a, vector float b) { return __builtin_vsx_xvrecipdivsp (a, b); } |
| 104 |
vector double v2df_recip2 (vector double a, vector double b) { return __builtin_vsx_xvrecipdivdp (a, b); } |