| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3 -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
void |
| 7 |
f1 (int32_t *restrict y, int32_t *restrict x, int32_t *restrict index) |
| 8 |
{ |
| 9 |
for (int i = 0; i < 100; ++i) |
| 10 |
{ |
| 11 |
y[i * 2] = (index[i * 2] < 128 |
| 12 |
? x[index[i * 2]] + 1 |
| 13 |
: 1); |
| 14 |
y[i * 2 + 1] = (index[i * 2 + 1] < 128 |
| 15 |
? x[index[i * 2 + 1]] + 2 |
| 16 |
: 2); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
f2 (int32_t *restrict y, int32_t *restrict x, uint32_t *restrict index) |
| 22 |
{ |
| 23 |
for (int i = 0; i < 100; ++i) |
| 24 |
{ |
| 25 |
y[i * 2] = (index[i * 2] < 128 |
| 26 |
? x[index[i * 2]] + 1 |
| 27 |
: 1); |
| 28 |
y[i * 2 + 1] = (index[i * 2 + 1] < 128 |
| 29 |
? x[index[i * 2 + 1]] + 2 |
| 30 |
: 2); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
void |
| 35 |
f3 (int32_t *restrict y, int32_t *restrict x, uint64_t *restrict index) |
| 36 |
{ |
| 37 |
for (int i = 0; i < 100; ++i) |
| 38 |
{ |
| 39 |
y[i * 2] = (index[i * 2] < 128 |
| 40 |
? x[index[i * 2]] + 1 |
| 41 |
: 1); |
| 42 |
y[i * 2 + 1] = (index[i * 2 + 1] < 128 |
| 43 |
? x[index[i * 2 + 1]] + 2 |
| 44 |
: 2); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
void |
| 49 |
f4 (int64_t *restrict y, int64_t *restrict x, uint64_t *restrict index) |
| 50 |
{ |
| 51 |
for (int i = 0; i < 100; ++i) |
| 52 |
{ |
| 53 |
y[i * 2] = (index[i * 2] < 128 |
| 54 |
? x[index[i * 2]] + 1 |
| 55 |
: 1); |
| 56 |
y[i * 2 + 1] = (index[i * 2 + 1] < 128 |
| 57 |
? x[index[i * 2 + 1]] + 2 |
| 58 |
: 2); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/* { dg-final { scan-assembler-times {\tld1w\tz[0-9]+\.s, p[0-7]/z, \[x[0-9]+, z[0-9]+\.s, sxtw #?2\]} 1 } } */ |
| 63 |
/* { dg-final { scan-assembler-times {\tld1w\tz[0-9]+\.s, p[0-7]/z, \[x[0-9]+, z[0-9]+\.s, uxtw #?2\]} 1 } } */ |
| 64 |
/* { dg-final { scan-assembler-times {\tld1w\tz[0-9]+\.d, p[0-7]/z, \[x[0-9]+, z[0-9]+\.d, lsl #?2\]} 1 } } */ |
| 65 |
/* { dg-final { scan-assembler-times {\tld1d\tz[0-9]+\.d, p[0-7]/z, \[x[0-9]+, z[0-9]+\.d, lsl #?3\]} 1 } } */ |