Debian Codegraph @

gcc/testsuite/gcc.target/arm/simd/mve-vshr.c

raw
1 /* { dg-do assemble } */
2 /* { dg-require-effective-target arm_v8_1m_mve_ok } */
3 /* { dg-add-options arm_v8_1m_mve } */
4 /* { dg-additional-options "-O3" } */
5
6 #include <stdint.h>
7
8 #define FUNC(SIGN, TYPE, BITS, NB, OP, NAME) \
9 void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, TYPE##BITS##_t *a, TYPE##BITS##_t *b) { \
10 int i; \
11 for (i=0; i<NB; i++) { \
12 if ((unsigned)b[i] >= (unsigned)(BITS)) \
13 __builtin_unreachable(); \
14 dest[i] = a[i] OP b[i]; \
15 } \
16 }
17
18 #define FUNC_IMM(SIGN, TYPE, BITS, NB, OP, NAME) \
19 void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, TYPE##BITS##_t *a) { \
20 int i; \
21 for (i=0; i<NB; i++) { \
22 dest[i] = a[i] OP 5; \
23 } \
24 }
25
26 /* 64-bit vectors. */
27 FUNC(s, int, 32, 2, >>, vshr)
28 FUNC(u, uint, 32, 2, >>, vshr)
29 FUNC(s, int, 16, 4, >>, vshr)
30 FUNC(u, uint, 16, 4, >>, vshr)
31 FUNC(s, int, 8, 8, >>, vshr)
32 FUNC(u, uint, 8, 8, >>, vshr)
33
34 /* 128-bit vectors. */
35 FUNC(s, int, 32, 4, >>, vshr)
36 FUNC(u, uint, 32, 4, >>, vshr)
37 FUNC(s, int, 16, 8, >>, vshr)
38 FUNC(u, uint, 16, 8, >>, vshr)
39 FUNC(s, int, 8, 16, >>, vshr)
40 FUNC(u, uint, 8, 16, >>, vshr)
41
42 /* 64-bit vectors. */
43 FUNC_IMM(s, int, 32, 2, >>, vshrimm)
44 FUNC_IMM(u, uint, 32, 2, >>, vshrimm)
45 FUNC_IMM(s, int, 16, 4, >>, vshrimm)
46 FUNC_IMM(u, uint, 16, 4, >>, vshrimm)
47 FUNC_IMM(s, int, 8, 8, >>, vshrimm)
48 FUNC_IMM(u, uint, 8, 8, >>, vshrimm)
49
50 /* 128-bit vectors. */
51 FUNC_IMM(s, int, 32, 4, >>, vshrimm)
52 FUNC_IMM(u, uint, 32, 4, >>, vshrimm)
53 FUNC_IMM(s, int, 16, 8, >>, vshrimm)
54 FUNC_IMM(u, uint, 16, 8, >>, vshrimm)
55 FUNC_IMM(s, int, 8, 16, >>, vshrimm)
56 FUNC_IMM(u, uint, 8, 16, >>, vshrimm)
57
58 /* MVE has only 128-bit vectors, so we can vectorize only half of the
59 functions above. */
60 /* Vector right shifts use vneg and left shifts. */
61 /* { dg-final { scan-assembler-times {vshl.s[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */
62 /* { dg-final { scan-assembler-times {vshl.u[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */
63 /* { dg-final { scan-assembler-times {vneg.s[0-9]+\tq[0-9]+, q[0-9]+} 6 } } */
64
65
66 /* Shift by immediate. */
67 /* { dg-final { scan-assembler-times {vshr.s[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */
68 /* { dg-final { scan-assembler-times {vshr.u[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */