| 1 |
/* { dg-do compile } */ |
| 2 |
|
| 3 |
#define N 16 |
| 4 |
|
| 5 |
void |
| 6 |
f1 (int *restrict y, int *restrict x1, int *restrict x2, |
| 7 |
int *restrict indices) |
| 8 |
{ |
| 9 |
for (int i = 0; i < N; ++i) |
| 10 |
{ |
| 11 |
y[i * 2] = (indices[i * 2] < N * 2 |
| 12 |
? x1[indices[i * 2]] + 1 |
| 13 |
: 1); |
| 14 |
y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2 |
| 15 |
? x2[indices[i * 2 + 1]] + 2 |
| 16 |
: 2); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
f2 (int *restrict y, int *restrict x, int *restrict indices) |
| 22 |
{ |
| 23 |
for (int i = 0; i < N; ++i) |
| 24 |
{ |
| 25 |
y[i * 2] = (indices[i * 2] < N * 2 |
| 26 |
? x[indices[i * 2]] + 1 |
| 27 |
: 1); |
| 28 |
y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2 |
| 29 |
? x[indices[i * 2 + 1] * 2] + 2 |
| 30 |
: 2); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
void |
| 35 |
f3 (int *restrict y, int *restrict x, int *restrict indices) |
| 36 |
{ |
| 37 |
for (int i = 0; i < N; ++i) |
| 38 |
{ |
| 39 |
y[i * 2] = (indices[i * 2] < N * 2 |
| 40 |
? x[indices[i * 2]] + 1 |
| 41 |
: 1); |
| 42 |
y[i * 2 + 1] = (((unsigned int *)indices)[i * 2 + 1] < N * 2 |
| 43 |
? x[((unsigned int *) indices)[i * 2 + 1]] + 2 |
| 44 |
: 2); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/* We do not want to see a two-lane .MASK_LOAD or .MASK_GATHER_LOAD since |
| 49 |
the gathers are different on each lane. This is a bit fragile and |
| 50 |
should possibly be turned into a runtime test. */ |
| 51 |
/* { dg-final { scan-tree-dump-not "stmt 1 \[^\r\n\]* = .MASK" vect } } */ |