Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/shift-run.c

raw
1 /* { dg-do run { target { riscv_v } } } */
2 /* { dg-additional-options "-std=c99 -fno-vect-cost-model -mrvv-vector-bits=zvl" } */
3
4 #include "shift-template.h"
5
6 #include <assert.h>
7
8 #define SZ 512
9
10 #define RUN(TYPE,VAL) \
11 TYPE a##TYPE[SZ]; \
12 TYPE b##TYPE[SZ]; \
13 for (int i = 0; i < SZ; i++) \
14 { \
15 a##TYPE[i] = VAL; \
16 b##TYPE[i] = i % 4; \
17 } \
18 vshl_##TYPE (a##TYPE, a##TYPE, b##TYPE, SZ); \
19 for (int i = 0; i < SZ; i++) \
20 assert (a##TYPE[i] == (VAL << (i % 4)));
21
22 #define RUN2(TYPE,VAL) \
23 TYPE as##TYPE[SZ]; \
24 TYPE bs##TYPE[SZ]; \
25 for (int i = 0; i < SZ; i++) \
26 { \
27 as##TYPE[i] = VAL; \
28 bs##TYPE[i] = i % 4; \
29 } \
30 vshiftr_##TYPE (as##TYPE, as##TYPE, bs##TYPE, SZ); \
31 for (int i = 0; i < SZ; i++) \
32 assert (as##TYPE[i] == (VAL >> (i % 4)));
33
34 #define RUN_ALL() \
35 RUN(int8_t, 1) \
36 RUN(uint8_t, 2) \
37 RUN(int16_t, 1) \
38 RUN(uint16_t, 2) \
39 RUN(int32_t, 3) \
40 RUN(uint32_t, 4) \
41 RUN(int64_t, 5) \
42 RUN(uint64_t, 6) \
43 RUN2(int8_t, -7) \
44 RUN2(uint8_t, 8) \
45 RUN2(int16_t, -7) \
46 RUN2(uint16_t, 8) \
47 RUN2(int32_t, -9) \
48 RUN2(uint32_t, 10) \
49 RUN2(int64_t, -11) \
50 RUN2(uint64_t, 12)
51
52 int main ()
53 {
54 RUN_ALL()
55 }