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, \
9 TYPE *__restrict pred, int count) \
10 { \
11 for (int i = 0; i < count; ++i) \
12 x[i] = (pred[i] != 1) ? (x[i] < y[i] ? x[i] : y[i]) : 4; \
13 }
14
15 #define DO_IMMEDIATE_OPS(VALUE, TYPE) \
16 void __attribute__ ((noclone)) \
17 varithimm_##VALUE##_##TYPE (TYPE *__restrict x, TYPE *__restrict pred, \
18 int count) \
19 { \
20 for (int i = 0; i < count; ++i) \
21 x[i] = (pred[i] != 1) ? (x[i] < (TYPE) VALUE ? x[i] : (TYPE) VALUE) : 4; \
22 }
23
24 #define DO_ARITH_OPS(REG, IMM, TYPE) \
25 REG (TYPE); \
26 IMM (2, TYPE); \
27 IMM (86, TYPE); \
28 IMM (109, TYPE); \
29 IMM (141, TYPE); \
30 IMM (229, TYPE); \
31 IMM (255, TYPE); \
32 IMM (992137445376, TYPE);
33
34 #define TEST_ALL(REG, IMM) \
35 DO_ARITH_OPS (REG, IMM, uint8_t) \
36 DO_ARITH_OPS (REG, IMM, uint16_t) \
37 DO_ARITH_OPS (REG, IMM, uint32_t) \
38 DO_ARITH_OPS (REG, IMM, uint64_t)
39
40 TEST_ALL (DO_REGREG_OPS, DO_IMMEDIATE_OPS)
41
42 /* Two per test case < 64 bits with wide-enough type:*/
43 /* { dg-final { scan-assembler-times {uminv64si3_exec} 20 } } */
44 /* { dg-final { scan-assembler-not {uminv64si3/0} } } */
45 /* { dg-final { scan-assembler-not {\tv_writelane_b32\tv[0-9]+, vcc_??, 0} } } */
46
47 /* Two per test case with wide-enough type:*/
48 /* { dg-final { scan-assembler-times {\tv_cmp_gt_i32\tvcc, s[0-9]+, v[0-9]+} 56 } } */
49 /* { dg-final { scan-assembler-not {\ts_cmpk_lg_u32\tvcc_lo, 0} } } */
50
51 /* One per 64-bit test case: */
52 /* { dg-final { scan-assembler-times {\tv_cmp_ne_u64\ts\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], 1} 8 } } */
53 /* { dg-final { scan-assembler-times {\tv_cmp_lt_u64\tvcc, v[[0-9]+:[0-9]+], v[[0-9]+:[0-9]+]} 8 } } */