Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-cond-arith-6.c

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