Add IFN_COND_{MUL,DIV,MOD,RDIV}
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-cond-arith-1.c
blobd52e81e9109cc4d81de84adf370b2322799c8c27
1 /* { dg-additional-options "-fdump-tree-optimized -fno-trapping-math -ffinite-math-only" } */
3 #include "tree-vect.h"
5 #define N (VECTOR_BITS * 11 / 64 + 3)
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))
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 { \
18 double truev = OP (b[i], x); \
19 a[i] = b[i] < 100 ? truev : b[i]; \
20 } \
23 #define TEST(OP) \
24 { \
25 f_##OP (a, b, 10); \
26 for (int i = 0; i < N; ++i) \
27 { \
28 int bval = (i % 17) * 10; \
29 int truev = OP (bval, 10); \
30 if (a[i] != (bval < 100 ? truev : bval)) \
31 __builtin_abort (); \
32 asm volatile ("" ::: "memory"); \
33 } \
36 #define FOR_EACH_OP(T) \
37 T (add) \
38 T (sub) \
39 T (mul) \
40 T (div) \
41 T (__builtin_fmax) \
42 T (__builtin_fmin)
44 FOR_EACH_OP (DEF)
46 int
47 main (void)
49 double a[N], b[N];
50 for (int i = 0; i < N; ++i)
52 b[i] = (i % 17) * 10;
53 asm volatile ("" ::: "memory");
55 FOR_EACH_OP (TEST)
56 return 0;
59 /* { dg-final { scan-tree-dump { = \.COND_ADD} "optimized" { target vect_double_cond_arith } } } */
60 /* { dg-final { scan-tree-dump { = \.COND_SUB} "optimized" { target vect_double_cond_arith } } } */
61 /* { dg-final { scan-tree-dump { = \.COND_MUL} "optimized" { target vect_double_cond_arith } } } */
62 /* { dg-final { scan-tree-dump { = \.COND_RDIV} "optimized" { target vect_double_cond_arith } } } */
63 /* { dg-final { scan-tree-dump { = \.COND_MAX} "optimized" { target vect_double_cond_arith } } } */
64 /* { dg-final { scan-tree-dump { = \.COND_MIN} "optimized" { target vect_double_cond_arith } } } */