1/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ 2/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ 3/* { dg-require-effective-target powerpc_vsx_ok } */ 4/* { dg-options "-O2 -ftree-vectorize -mcpu=power7 -ffast-math" } */ 5/* { dg-final { scan-assembler "xvaddsp" } } */ 6/* { dg-final { scan-assembler "xvsubsp" } } */ 7/* { dg-final { scan-assembler "xvmulsp" } } */ 8/* { dg-final { scan-assembler "xvdivsp" } } */ 9/* { dg-final { scan-assembler "xvmadd" } } */ 10/* { dg-final { scan-assembler "xvmsub" } } */ 11/* { dg-final { scan-assembler "xvsqrtsp" } } */ 12/* { dg-final { scan-assembler "xvcpsgnsp" } } */ 13/* { dg-final { scan-assembler "xvrspim" } } */ 14/* { dg-final { scan-assembler "xvrspip" } } */ 15/* { dg-final { scan-assembler "xvrspiz" } } */ 16/* { dg-final { scan-assembler "xvrspic" } } */ 17/* { dg-final { scan-assembler "xvrspi " } } */ 18 19#ifndef SIZE 20#define SIZE 1024 21#endif 22 23float a[SIZE] __attribute__((__aligned__(32))); 24float b[SIZE] __attribute__((__aligned__(32))); 25float c[SIZE] __attribute__((__aligned__(32))); 26float d[SIZE] __attribute__((__aligned__(32))); 27float e[SIZE] __attribute__((__aligned__(32))); 28 29void 30vector_add (void) 31{ 32 int i; 33 34 for (i = 0; i < SIZE; i++) 35 a[i] = b[i] + c[i]; 36} 37 38void 39vector_subtract (void) 40{ 41 int i; 42 43 for (i = 0; i < SIZE; i++) 44 a[i] = b[i] - c[i]; 45} 46 47void 48vector_multiply (void) 49{ 50 int i; 51 52 for (i = 0; i < SIZE; i++) 53 a[i] = b[i] * c[i]; 54} 55 56void 57vector_multiply_add (void) 58{ 59 int i; 60 61 for (i = 0; i < SIZE; i++) 62 a[i] = (b[i] * c[i]) + d[i]; 63} 64 65void 66vector_multiply_subtract (void) 67{ 68 int i; 69 70 for (i = 0; i < SIZE; i++) 71 a[i] = (b[i] * c[i]) - d[i]; 72} 73 74void 75vector_divide (void) 76{ 77 int i; 78 79 for (i = 0; i < SIZE; i++) 80 a[i] = b[i] / c[i]; 81} 82 83extern float sqrtf (float); 84extern float floorf (float); 85extern float ceilf (float); 86extern float truncf (float); 87extern float nearbyintf (float); 88extern float rintf (float); 89extern float copysignf (float, float); 90 91void 92vector_sqrt (void) 93{ 94 int i; 95 96 for (i = 0; i < SIZE; i++) 97 a[i] = sqrtf (b[i]); 98} 99 100void 101vector_floor (void) 102{ 103 int i; 104 105 for (i = 0; i < SIZE; i++) 106 a[i] = floorf (b[i]); 107} 108 109void 110vector_ceil (void) 111{ 112 int i; 113 114 for (i = 0; i < SIZE; i++) 115 a[i] = ceilf (b[i]); 116} 117 118void 119vector_trunc (void) 120{ 121 int i; 122 123 for (i = 0; i < SIZE; i++) 124 a[i] = truncf (b[i]); 125} 126 127void 128vector_nearbyint (void) 129{ 130 int i; 131 132 for (i = 0; i < SIZE; i++) 133 a[i] = nearbyintf (b[i]); 134} 135 136void 137vector_rint (void) 138{ 139 int i; 140 141 for (i = 0; i < SIZE; i++) 142 a[i] = rintf (b[i]); 143} 144 145void 146vector_copysign (void) 147{ 148 int i; 149 150 for (i = 0; i < SIZE; i++) 151 a[i] = copysignf (b[i], c[i]); 152} 153