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