| 1 |
#include "tree-vect.h" |
| 2 |
|
| 3 |
extern void abort (void); |
| 4 |
|
| 5 |
static void |
| 6 |
foo (int *out, const int *lp, unsigned samples) |
| 7 |
{ |
| 8 |
int x, target; |
| 9 |
for (x = 0, target = 0; x < (int)samples; x += 2, target++) |
| 10 |
{ |
| 11 |
out[x] = lp[target]; |
| 12 |
out[x - 1] = out[x - 2] + out[x]; |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
static void |
| 17 |
foo_novec (int *out, const int *lp, unsigned samples) |
| 18 |
{ |
| 19 |
int x, target; |
| 20 |
for (x = 0, target = 0; x < (int)samples; x += 2, target++) |
| 21 |
{ |
| 22 |
out[x] = lp[target]; |
| 23 |
out[x - 1] = out[x - 2] + out[x]; |
| 24 |
__asm__ volatile ("" : : : "memory"); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
int main(void) |
| 29 |
{ |
| 30 |
const int lp[25] = { |
| 31 |
0, 2, 4, 6, 8, |
| 32 |
10, 12, 14, 16, |
| 33 |
18, 20, 22, 24, |
| 34 |
26, 28, 30, 32, |
| 35 |
34, 36, 38, 40, |
| 36 |
42, 44, 46, 48, |
| 37 |
}; |
| 38 |
int out[49] = {0}; |
| 39 |
int out2[49] = {0}; |
| 40 |
int s; |
| 41 |
|
| 42 |
check_vect (); |
| 43 |
|
| 44 |
foo (out + 2, lp + 1, 48); |
| 45 |
foo_novec (out2 + 2, lp + 1, 48); |
| 46 |
|
| 47 |
#pragma GCC novector |
| 48 |
for (s = 0; s < 49; s++) |
| 49 |
if (out[s] != out2[s]) |
| 50 |
abort (); |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |
| 54 |
|