i386: Adjust rtx cost for imulq and imulw [PR115749]
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-cond-arith-1.c
blob5138712731f245eb1f17ef2e9e02e333c8e214de
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 _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 < 100 ? truev : bval)) \
32 __builtin_abort (); \
33 asm volatile ("" ::: "memory"); \
34 } \
37 #define FOR_EACH_OP(T) \
38 T (add) \
39 T (sub) \
40 T (mul) \
41 T (div) \
42 T (__builtin_fmax) \
43 T (__builtin_fmin)
45 FOR_EACH_OP (DEF)
47 int
48 main (void)
50 double a[N], b[N];
51 for (int i = 0; i < N; ++i)
53 b[i] = (i % 17) * 10;
54 asm volatile ("" ::: "memory");
56 FOR_EACH_OP (TEST)
57 return 0;
60 /* { dg-final { scan-tree-dump { = \.COND_ADD} "optimized" { target vect_double_cond_arith } } } */
61 /* { dg-final { scan-tree-dump { = \.COND_SUB} "optimized" { target vect_double_cond_arith } } } */
62 /* { dg-final { scan-tree-dump { = \.COND_MUL} "optimized" { target vect_double_cond_arith } } } */
63 /* { dg-final { scan-tree-dump { = \.COND_RDIV} "optimized" { target vect_double_cond_arith } } } */
64 /* { dg-final { scan-tree-dump { = \.COND_MAX} "optimized" { target vect_double_cond_arith } } } */
65 /* { dg-final { scan-tree-dump { = \.COND_MIN} "optimized" { target vect_double_cond_arith } } } */