1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-vectorize -dp" } */
3
4 #include <stdint.h>
5
6 #define DO_REGREG_OPS(TYPE) \
7 void __attribute__ ((noclone)) \
8 varith_##TYPE##_reg (TYPE *__restrict x, TYPE *__restrict y, int count) \
9 { \
10 for (int i = 0; i < count; ++i) \
11 x[i] = x[i] > y[i] ? x[i] : y[i]; \
12 }
13
14 #define DO_IMMEDIATE_OPS(VALUE, TYPE) \
15 void __attribute__ ((noclone)) \
16 varithimm_##VALUE##_##TYPE (TYPE *__restrict x, int count) \
17 { \
18 for (int i = 0; i < count; ++i) \
19 x[i] = x[i] > (TYPE) VALUE ? x[i] : (TYPE) VALUE; \
20 }
21
22 #define DO_ARITH_OPS(REG, IMM, TYPE) \
23 REG (TYPE); \
24 IMM (2, TYPE); \
25 IMM (86, TYPE); \
26 IMM (109, TYPE); \
27 IMM (141, TYPE); \
28 IMM (229, TYPE); \
29 IMM (255, TYPE); \
30 IMM (992137445376, TYPE);
31
32 #define TEST_ALL(REG, IMM) \
33 DO_ARITH_OPS (REG, IMM, uint8_t) \
34 DO_ARITH_OPS (REG, IMM, uint16_t) \
35 DO_ARITH_OPS (REG, IMM, uint32_t) \
36 DO_ARITH_OPS (REG, IMM, uint64_t)
37
38 TEST_ALL (DO_REGREG_OPS, DO_IMMEDIATE_OPS)
39
40 /* One per 64-bit test case: */
41 /* { dg-final { scan-assembler-times {vec_cmpv64didi} 8 } } */
42
43 /* Two per test case with wide-enough type:*/
44 /* { dg-final { scan-assembler-times {\tv_cmp_gt_u64\tvcc, v[[0-9]+:[0-9]+], v[[0-9]+:[0-9]+]} 8 } } */
45 /* { dg-final { scan-assembler-times {\tv_cmpx_gt_i32\tvcc, s[0-9]+, v[0-9]+} 56 } } */