| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
#define TEST(DATA_TYPE, PRED_TYPE, NAME, OP) \ |
| 7 |
void __attribute__ ((noinline, noclone)) \ |
| 8 |
test_##DATA_TYPE##_##PRED_TYPE##_##NAME (DATA_TYPE *__restrict x, \ |
| 9 |
DATA_TYPE *__restrict y, \ |
| 10 |
DATA_TYPE *__restrict z, \ |
| 11 |
PRED_TYPE *__restrict pred, \ |
| 12 |
int n) \ |
| 13 |
{ \ |
| 14 |
for (int i = 0; i < n; ++i) \ |
| 15 |
x[i] = pred[i] != 1 ? y[i] OP z[i] : y[i]; \ |
| 16 |
} |
| 17 |
|
| 18 |
#define TEST_INT_TYPE(DATA_TYPE, PRED_TYPE) \ |
| 19 |
TEST (DATA_TYPE, PRED_TYPE, div, /) |
| 20 |
|
| 21 |
#define TEST_FP_TYPE(DATA_TYPE, PRED_TYPE) \ |
| 22 |
TEST (DATA_TYPE, PRED_TYPE, add, +) \ |
| 23 |
TEST (DATA_TYPE, PRED_TYPE, sub, -) \ |
| 24 |
TEST (DATA_TYPE, PRED_TYPE, mul, *) \ |
| 25 |
TEST (DATA_TYPE, PRED_TYPE, div, /) |
| 26 |
|
| 27 |
#define TEST_ALL \ |
| 28 |
TEST_INT_TYPE (int32_t, int8_t) \ |
| 29 |
TEST_INT_TYPE (uint32_t, int8_t) \ |
| 30 |
TEST_INT_TYPE (int32_t, int16_t) \ |
| 31 |
TEST_INT_TYPE (uint32_t, int16_t) \ |
| 32 |
TEST_INT_TYPE (int64_t, int8_t) \ |
| 33 |
TEST_INT_TYPE (uint64_t, int8_t) \ |
| 34 |
TEST_INT_TYPE (int64_t, int16_t) \ |
| 35 |
TEST_INT_TYPE (uint64_t, int16_t) \ |
| 36 |
TEST_INT_TYPE (int64_t, int32_t) \ |
| 37 |
TEST_INT_TYPE (uint64_t, int32_t) \ |
| 38 |
TEST_FP_TYPE (float, int8_t) \ |
| 39 |
TEST_FP_TYPE (float, int16_t) \ |
| 40 |
TEST_FP_TYPE (double, int8_t) \ |
| 41 |
TEST_FP_TYPE (double, int16_t) \ |
| 42 |
TEST_FP_TYPE (double, int32_t) |
| 43 |
|
| 44 |
TEST_ALL |
| 45 |
|
| 46 |
/* { dg-final { scan-assembler-times {\tsdiv\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 47 |
/* { dg-final { scan-assembler-times {\tudiv\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 48 |
/* { dg-final { scan-assembler-times {\tsdiv\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 49 |
/* { dg-final { scan-assembler-times {\tudiv\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 50 |
|
| 51 |
/* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 52 |
/* { dg-final { scan-assembler-times {\tfadd\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 53 |
|
| 54 |
/* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 55 |
/* { dg-final { scan-assembler-times {\tfsub\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 56 |
|
| 57 |
/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 58 |
/* { dg-final { scan-assembler-times {\tfmul\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 59 |
|
| 60 |
/* { dg-final { scan-assembler-times {\tfdiv\tz[0-9]+\.s, p[0-7]/m,} 6 } } */ |
| 61 |
/* { dg-final { scan-assembler-times {\tfdiv\tz[0-9]+\.d, p[0-7]/m,} 14 } } */ |
| 62 |
|
| 63 |
/* { dg-final { scan-assembler-not {\tsel\t} } } */ |