| 1 |
/* { dg-additional-options "-fdump-tree-optimized" } */ |
| 2 |
|
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
#define N (VECTOR_BITS * 11 / 64 + 3) |
| 6 |
|
| 7 |
#define add(A, B) ((A) + (B)) |
| 8 |
#define sub(A, B) ((A) - (B)) |
| 9 |
#define mul(A, B) ((A) * (B)) |
| 10 |
#define div(A, B) ((A) / (B)) |
| 11 |
|
| 12 |
#define DEF(OP) \ |
| 13 |
void __attribute__ ((noipa)) \ |
| 14 |
f_##OP (double *restrict a, double *restrict b, double x) \ |
| 15 |
{ \ |
| 16 |
for (int i = 0; i < N; ++i) \ |
| 17 |
a[i] = b[i] < 100 ? OP (b[i], x) : b[i]; \ |
| 18 |
} |
| 19 |
|
| 20 |
#define TEST(OP) \ |
| 21 |
{ \ |
| 22 |
f_##OP (a, b, 10); \ |
| 23 |
_Pragma("GCC novector") \ |
| 24 |
for (int i = 0; i < N; ++i) \ |
| 25 |
{ \ |
| 26 |
int bval = (i % 17) * 10; \ |
| 27 |
int truev = OP (bval, 10); \ |
| 28 |
if (a[i] != (bval < 100 ? truev : bval)) \ |
| 29 |
__builtin_abort (); \ |
| 30 |
asm volatile ("" ::: "memory"); \ |
| 31 |
} \ |
| 32 |
} |
| 33 |
|
| 34 |
#define FOR_EACH_OP(T) \ |
| 35 |
T (add) \ |
| 36 |
T (sub) \ |
| 37 |
T (mul) \ |
| 38 |
T (div) |
| 39 |
|
| 40 |
FOR_EACH_OP (DEF) |
| 41 |
|
| 42 |
int |
| 43 |
main (void) |
| 44 |
{ |
| 45 |
double a[N], b[N]; |
| 46 |
for (int i = 0; i < N; ++i) |
| 47 |
{ |
| 48 |
b[i] = (i % 17) * 10; |
| 49 |
asm volatile ("" ::: "memory"); |
| 50 |
} |
| 51 |
FOR_EACH_OP (TEST) |
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?ADD} "optimized" { target vect_double_cond_arith } } } */ |
| 56 |
/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?SUB} "optimized" { target vect_double_cond_arith } } } */ |
| 57 |
/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?MUL} "optimized" { target vect_double_cond_arith } } } */ |
| 58 |
/* { dg-final { scan-tree-dump { = \.COND_(LEN_)?RDIV} "optimized" { target vect_double_cond_arith } } } */ |
| 59 |
/* { dg-final { scan-tree-dump-not {VEC_COND_EXPR} "optimized" { target vect_double_cond_arith } } } */ |