| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target avx } */ |
| 3 |
/* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic" } */ |
| 4 |
|
| 5 |
#include "avx-check.h" |
| 6 |
|
| 7 |
#define N 16 |
| 8 |
|
| 9 |
float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; |
| 10 |
float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 11 |
float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; |
| 12 |
|
| 13 |
static void |
| 14 |
__attribute__ ((noinline)) |
| 15 |
avx_test () |
| 16 |
{ |
| 17 |
int i; |
| 18 |
float a[N]; |
| 19 |
|
| 20 |
/* Strided access. Vectorizable on platforms that support load of strided |
| 21 |
accesses (extract of even/odd vector elements). */ |
| 22 |
for (i = 0; i < N/2; i++) |
| 23 |
{ |
| 24 |
a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; |
| 25 |
d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; |
| 26 |
} |
| 27 |
|
| 28 |
/* Check results. */ |
| 29 |
for (i = 0; i < N/2; i++) |
| 30 |
{ |
| 31 |
if (a[i] != b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i] |
| 32 |
|| d[i] != b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]) |
| 33 |
abort(); |
| 34 |
} |
| 35 |
} |