Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_narrow_shift-2.c

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-march=rv32gcv_zvfh -mabi=ilp32d -mrvv-vector-bits=scalable -fno-vect-cost-model" } */
3
4 #include <stdint-gcc.h>
5
6 #define DEF_LOOP(TYPE1, TYPE2) \
7 void __attribute__ ((noipa)) \
8 test_##TYPE1##_##TYPE2 (TYPE2 *__restrict r, TYPE2 *__restrict a, \
9 TYPE1 *__restrict b, TYPE2 shift, int n) \
10 { \
11 for (int i = 0; i < n; ++i) \
12 r[i] = a[i] > 20 ? (TYPE2) (b[i] >> shift) : r[i]; \
13 }
14
15 #define TEST_ALL(T) \
16 T (int16_t, int8_t) \
17 T (int32_t, int16_t) \
18 T (int64_t, int32_t) \
19 T (uint16_t, uint8_t) \
20 T (uint32_t, uint16_t) \
21 T (uint64_t, uint32_t)
22
23 TEST_ALL (DEF_LOOP)
24
25 /* For int8_t and uint8_t, they are extended to int32_t and then shifted, so
26 int8_t and uint8_t are use vnsra.wx and vnsra.wx's dest is used not by vmerge
27 but by vncvt, so vncvt + vmerge will combine to a mask operator. */
28 /* { dg-final { scan-assembler-times {vnsrl\.wx\t} 2 } } */
29 /* { dg-final { scan-assembler-times {vnsra\.wx\t} 4 } } */
30 /* { dg-final { scan-assembler-not {\tvmerge\.vvm\t} } } */