1 /* { dg-skip-if "" { arm*-*-* } } */
2 /* { dg-do compile } */
3 /* { dg-options "-O3" } */
4 
5 #include <arm_neon.h>
6 
7 #define TEST_SHIFT(name, rettype, intype, fs, rs) \
8   rettype test_ ## name ## _ ## fs ## _zero_high \
9 		(intype a) \
10 	{ \
11 		return vcombine_ ## rs (name ## _ ## fs (a, 4), \
12 					vdup_n_ ## rs (0)); \
13 	}
14 
15 TEST_SHIFT (vshrn_n, int8x16_t, int16x8_t, s16, s8)
16 TEST_SHIFT (vshrn_n, int16x8_t, int32x4_t, s32, s16)
17 TEST_SHIFT (vshrn_n, int32x4_t, int64x2_t, s64, s32)
18 TEST_SHIFT (vshrn_n, uint8x16_t, uint16x8_t, u16, u8)
19 TEST_SHIFT (vshrn_n, uint16x8_t, uint32x4_t, u32, u16)
20 TEST_SHIFT (vshrn_n, uint32x4_t, uint64x2_t, u64, u32)
21 
22 TEST_SHIFT (vrshrn_n, int8x16_t, int16x8_t, s16, s8)
23 TEST_SHIFT (vrshrn_n, int16x8_t, int32x4_t, s32, s16)
24 TEST_SHIFT (vrshrn_n, int32x4_t, int64x2_t, s64, s32)
25 TEST_SHIFT (vrshrn_n, uint8x16_t, uint16x8_t, u16, u8)
26 TEST_SHIFT (vrshrn_n, uint16x8_t, uint32x4_t, u32, u16)
27 TEST_SHIFT (vrshrn_n, uint32x4_t, uint64x2_t, u64, u32)
28 
29 TEST_SHIFT (vqshrn_n, int8x16_t, int16x8_t, s16, s8)
30 TEST_SHIFT (vqshrn_n, int16x8_t, int32x4_t, s32, s16)
31 TEST_SHIFT (vqshrn_n, int32x4_t, int64x2_t, s64, s32)
32 TEST_SHIFT (vqshrn_n, uint8x16_t, uint16x8_t, u16, u8)
33 TEST_SHIFT (vqshrn_n, uint16x8_t, uint32x4_t, u32, u16)
34 TEST_SHIFT (vqshrn_n, uint32x4_t, uint64x2_t, u64, u32)
35 
36 TEST_SHIFT (vqrshrn_n, int8x16_t, int16x8_t, s16, s8)
37 TEST_SHIFT (vqrshrn_n, int16x8_t, int32x4_t, s32, s16)
38 TEST_SHIFT (vqrshrn_n, int32x4_t, int64x2_t, s64, s32)
39 TEST_SHIFT (vqrshrn_n, uint8x16_t, uint16x8_t, u16, u8)
40 TEST_SHIFT (vqrshrn_n, uint16x8_t, uint32x4_t, u32, u16)
41 TEST_SHIFT (vqrshrn_n, uint32x4_t, uint64x2_t, u64, u32)
42 
43 TEST_SHIFT (vqshrun_n, uint8x16_t, int16x8_t, s16, u8)
44 TEST_SHIFT (vqshrun_n, uint16x8_t, int32x4_t, s32, u16)
45 TEST_SHIFT (vqshrun_n, uint32x4_t, int64x2_t, s64, u32)
46 
47 TEST_SHIFT (vqrshrun_n, uint8x16_t, int16x8_t, s16, u8)
48 TEST_SHIFT (vqrshrun_n, uint16x8_t, int32x4_t, s32, u16)
49 TEST_SHIFT (vqrshrun_n, uint32x4_t, int64x2_t, s64, u32)
50 
51 #define TEST_UNARY(name, rettype, intype, fs, rs) \
52   rettype test_ ## name ## _ ## fs ## _zero_high \
53 		(intype a) \
54 	{ \
55 		return vcombine_ ## rs (name ## _ ## fs (a), \
56 					vdup_n_ ## rs (0)); \
57 	}
58 
59 TEST_UNARY (vmovn, int8x16_t, int16x8_t, s16, s8)
60 TEST_UNARY (vmovn, int16x8_t, int32x4_t, s32, s16)
61 TEST_UNARY (vmovn, int32x4_t, int64x2_t, s64, s32)
62 TEST_UNARY (vmovn, uint8x16_t, uint16x8_t, u16, u8)
63 TEST_UNARY (vmovn, uint16x8_t, uint32x4_t, u32, u16)
64 TEST_UNARY (vmovn, uint32x4_t, uint64x2_t, u64, u32)
65 
66 TEST_UNARY (vqmovun, uint8x16_t, int16x8_t, s16, u8)
67 TEST_UNARY (vqmovun, uint16x8_t, int32x4_t, s32, u16)
68 TEST_UNARY (vqmovun, uint32x4_t, int64x2_t, s64, u32)
69 
70 TEST_UNARY (vqmovn, int8x16_t, int16x8_t, s16, s8)
71 TEST_UNARY (vqmovn, int16x8_t, int32x4_t, s32, s16)
72 TEST_UNARY (vqmovn, int32x4_t, int64x2_t, s64, s32)
73 TEST_UNARY (vqmovn, uint8x16_t, uint16x8_t, u16, u8)
74 TEST_UNARY (vqmovn, uint16x8_t, uint32x4_t, u32, u16)
75 TEST_UNARY (vqmovn, uint32x4_t, uint64x2_t, u64, u32)
76 
77 #define TEST_ARITH(name, rettype, intype, fs, rs) \
78   rettype test_ ## name ## _ ## fs ## _zero_high \
79 		(intype a, intype b) \
80 	{ \
81 		return vcombine_ ## rs (name ## _ ## fs (a, b), \
82 					vdup_n_ ## rs (0)); \
83 	}
84 
85 TEST_ARITH (vaddhn, int8x16_t, int16x8_t, s16, s8)
86 TEST_ARITH (vaddhn, int16x8_t, int32x4_t, s32, s16)
87 TEST_ARITH (vaddhn, int32x4_t, int64x2_t, s64, s32)
88 TEST_ARITH (vaddhn, uint8x16_t, uint16x8_t, u16, u8)
89 TEST_ARITH (vaddhn, uint16x8_t, uint32x4_t, u32, u16)
90 TEST_ARITH (vaddhn, uint32x4_t, uint64x2_t, u64, u32)
91 
92 TEST_ARITH (vraddhn, int8x16_t, int16x8_t, s16, s8)
93 TEST_ARITH (vraddhn, int16x8_t, int32x4_t, s32, s16)
94 TEST_ARITH (vraddhn, int32x4_t, int64x2_t, s64, s32)
95 TEST_ARITH (vraddhn, uint8x16_t, uint16x8_t, u16, u8)
96 TEST_ARITH (vraddhn, uint16x8_t, uint32x4_t, u32, u16)
97 TEST_ARITH (vraddhn, uint32x4_t, uint64x2_t, u64, u32)
98 
99 TEST_ARITH (vsubhn, int8x16_t, int16x8_t, s16, s8)
100 TEST_ARITH (vsubhn, int16x8_t, int32x4_t, s32, s16)
101 TEST_ARITH (vsubhn, int32x4_t, int64x2_t, s64, s32)
102 TEST_ARITH (vsubhn, uint8x16_t, uint16x8_t, u16, u8)
103 TEST_ARITH (vsubhn, uint16x8_t, uint32x4_t, u32, u16)
104 TEST_ARITH (vsubhn, uint32x4_t, uint64x2_t, u64, u32)
105 
106 TEST_ARITH (vrsubhn, int8x16_t, int16x8_t, s16, s8)
107 TEST_ARITH (vrsubhn, int16x8_t, int32x4_t, s32, s16)
108 TEST_ARITH (vrsubhn, int32x4_t, int64x2_t, s64, s32)
109 TEST_ARITH (vrsubhn, uint8x16_t, uint16x8_t, u16, u8)
110 TEST_ARITH (vrsubhn, uint16x8_t, uint32x4_t, u32, u16)
111 TEST_ARITH (vrsubhn, uint32x4_t, uint64x2_t, u64, u32)
112 
113 /* { dg-final { scan-assembler-not "dup\\t" } } */
114 
115 /* { dg-final { scan-assembler-times "\\tshrn\\tv" 6} }  */
116 /* { dg-final { scan-assembler-times "\\trshrn\\tv" 6} }  */
117 /* { dg-final { scan-assembler-times "\\tsqshrn\\tv" 3} }  */
118 /* { dg-final { scan-assembler-times "\\tuqshrn\\tv" 3} }  */
119 /* { dg-final { scan-assembler-times "\\tsqrshrn\\tv" 3} }  */
120 /* { dg-final { scan-assembler-times "\\tuqrshrn\\tv" 3} }  */
121 /* { dg-final { scan-assembler-times "\\tsqshrun\\tv" 3} }  */
122 /* { dg-final { scan-assembler-times "\\tsqrshrun\\tv" 3} }  */
123 /* { dg-final { scan-assembler-times "\\txtn\\tv" 6} }  */
124 /* { dg-final { scan-assembler-times "\\tsqxtun\\tv" 3} }  */
125 /* { dg-final { scan-assembler-times "\\tuqxtn\\tv" 3} }  */
126 /* { dg-final { scan-assembler-times "\\tsqxtn\\tv" 3} }  */
127 /* { dg-final { scan-assembler-times "\\taddhn\\tv" 6} }  */
128 /* { dg-final { scan-assembler-times "\\tsubhn\\tv" 6} }  */
129 /* { dg-final { scan-assembler-times "\\trsubhn\\tv" 6} }  */
130 /* { dg-final { scan-assembler-times "\\traddhn\\tv" 6} }  */
131