Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_unary-6.c

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-march=rv64gcv_zvfh -mabi=lp64d -mrvv-vector-bits=scalable -fno-vect-cost-model" } */
3
4 #include <stdint-gcc.h>
5
6 #define abs(A) ((A) < 0 ? -(A) : (A))
7 #define neg(A) (-(A))
8 #define not(A) (~(A))
9
10 #define DEF_LOOP(TYPE1, TYPE2, COUNT, OP) \
11 void __attribute__ ((noipa)) \
12 test_##TYPE1##_##TYPE2##_##OP (TYPE2 *__restrict r, TYPE2 *__restrict a, \
13 TYPE2 *__restrict b, TYPE1 *__restrict pred) \
14 { \
15 for (int i = 0; i < COUNT; ++i) \
16 { \
17 TYPE2 bi = b[i]; \
18 r[i] = pred[i] ? OP (a[i]) : bi; \
19 } \
20 }
21
22 #define TEST_TYPES(T, TYPE1, TYPE2, COUNT) \
23 T (TYPE1, TYPE2, COUNT, abs) \
24 T (TYPE1, TYPE2, COUNT, neg) \
25 T (TYPE1, TYPE2, COUNT, not )
26
27 #define TEST_ALL(T) \
28 TEST_TYPES (T, int16_t, int8_t, 7) \
29 TEST_TYPES (T, int32_t, int8_t, 3) \
30 TEST_TYPES (T, int32_t, int16_t, 3) \
31 TEST_TYPES (T, int64_t, int8_t, 42) \
32 TEST_TYPES (T, int64_t, int16_t, 42) \
33 TEST_TYPES (T, int64_t, int32_t, 42)
34
35 TEST_ALL (DEF_LOOP)
36
37 /* NOTE: int abs operator is converted to vneg.v (or vsrub.vi) + vmax.vv */
38 /* { dg-final { scan-assembler-times {\tvrsub\.vi\tv[0-9]+,v[0-9]+} 12 } } */
39 /* { dg-final { scan-assembler-times {\tvmax\.vv\tv[0-9]+,v[0-9]+,v[0-9]+} 6 } } */
40 /* { dg-final { scan-assembler-times {\tvrsub\.vi\tv[0-9]+,v[0-9]+,0,v0\.t} 6 } } */
41 /* { dg-final { scan-assembler-times {\tvnot\.v\tv[0-9]+,v[0-9]+,v0\.t} 6 } } */
42 /* NOTE: int abs operator cannot combine the vmerge. */
43 /* { dg-final { scan-assembler-times {\tvf?merge\.v[vxi]m\t} 6 } } */