• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -fallow-half-arguments-and-returns -target-feature +mve.fp -verify -fsyntax-only %s
2 
3 #include <arm_mve.h>
4 
test_load_offsets(uint32x4_t addr32,uint64x2_t addr64)5 void test_load_offsets(uint32x4_t addr32, uint64x2_t addr64)
6 {
7   // Offsets that should be a multiple of 8 times 0,1,...,127
8   vldrdq_gather_base_s64(addr64, 0);
9   vldrdq_gather_base_s64(addr64, 8);
10   vldrdq_gather_base_s64(addr64, 2*8);
11   vldrdq_gather_base_s64(addr64, 125*8);
12   vldrdq_gather_base_s64(addr64, 126*8);
13   vldrdq_gather_base_s64(addr64, 127*8);
14   vldrdq_gather_base_s64(addr64, -125*8);
15   vldrdq_gather_base_s64(addr64, -126*8);
16   vldrdq_gather_base_s64(addr64, -127*8);
17   vldrdq_gather_base_s64(addr64, 128*8); // expected-error {{argument value 1024 is outside the valid range [-1016, 1016]}}
18   vldrdq_gather_base_s64(addr64, -128*8); // expected-error {{argument value -1024 is outside the valid range [-1016, 1016]}}
19   vldrdq_gather_base_s64(addr64, 4); // expected-error {{argument should be a multiple of 8}}
20   vldrdq_gather_base_s64(addr64, 1); // expected-error {{argument should be a multiple of 8}}
21 
22   // Offsets that should be a multiple of 4 times 0,1,...,127
23   vldrwq_gather_base_s32(addr32, 0);
24   vldrwq_gather_base_s32(addr32, 4);
25   vldrwq_gather_base_s32(addr32, 2*4);
26   vldrwq_gather_base_s32(addr32, 125*4);
27   vldrwq_gather_base_s32(addr32, 126*4);
28   vldrwq_gather_base_s32(addr32, 127*4);
29   vldrwq_gather_base_s32(addr32, -125*4);
30   vldrwq_gather_base_s32(addr32, -126*4);
31   vldrwq_gather_base_s32(addr32, -127*4);
32   vldrwq_gather_base_s32(addr32, 128*4); // expected-error {{argument value 512 is outside the valid range [-508, 508]}}
33   vldrwq_gather_base_s32(addr32, -128*4); // expected-error {{argument value -512 is outside the valid range [-508, 508]}}
34   vldrwq_gather_base_s32(addr32, 2); // expected-error {{argument should be a multiple of 4}}
35   vldrwq_gather_base_s32(addr32, 1); // expected-error {{argument should be a multiple of 4}}
36 
37   // Show that the polymorphic store intrinsics get the right set of
38   // error checks after overload resolution. These ones expand to the
39   // 8-byte granular versions...
40   vstrdq_scatter_base(addr64, 0, addr64);
41   vstrdq_scatter_base(addr64, 8, addr64);
42   vstrdq_scatter_base(addr64, 2*8, addr64);
43   vstrdq_scatter_base(addr64, 125*8, addr64);
44   vstrdq_scatter_base(addr64, 126*8, addr64);
45   vstrdq_scatter_base(addr64, 127*8, addr64);
46   vstrdq_scatter_base(addr64, -125*8, addr64);
47   vstrdq_scatter_base(addr64, -126*8, addr64);
48   vstrdq_scatter_base(addr64, -127*8, addr64);
49   vstrdq_scatter_base(addr64, 128*8, addr64); // expected-error {{argument value 1024 is outside the valid range [-1016, 1016]}}
50   vstrdq_scatter_base(addr64, -128*8, addr64); // expected-error {{argument value -1024 is outside the valid range [-1016, 1016]}}
51   vstrdq_scatter_base(addr64, 4, addr64); // expected-error {{argument should be a multiple of 8}}
52   vstrdq_scatter_base(addr64, 1, addr64); // expected-error {{argument should be a multiple of 8}}
53 
54   /// ... and these ones to the 4-byte.
55   vstrwq_scatter_base(addr32, 0, addr32);
56   vstrwq_scatter_base(addr32, 4, addr32);
57   vstrwq_scatter_base(addr32, 2*4, addr32);
58   vstrwq_scatter_base(addr32, 125*4, addr32);
59   vstrwq_scatter_base(addr32, 126*4, addr32);
60   vstrwq_scatter_base(addr32, 127*4, addr32);
61   vstrwq_scatter_base(addr32, -125*4, addr32);
62   vstrwq_scatter_base(addr32, -126*4, addr32);
63   vstrwq_scatter_base(addr32, -127*4, addr32);
64   vstrwq_scatter_base(addr32, 128*4, addr32); // expected-error {{argument value 512 is outside the valid range [-508, 508]}}
65   vstrwq_scatter_base(addr32, -128*4, addr32); // expected-error {{argument value -512 is outside the valid range [-508, 508]}}
66   vstrwq_scatter_base(addr32, 2, addr32); // expected-error {{argument should be a multiple of 4}}
67   vstrwq_scatter_base(addr32, 1, addr32); // expected-error {{argument should be a multiple of 4}}
68 }
69 
test_lane_indices(uint8x16_t v16,uint16x8_t v8,uint32x4_t v4,uint64x2_t v2)70 void test_lane_indices(uint8x16_t v16, uint16x8_t v8,
71                        uint32x4_t v4, uint64x2_t v2)
72 {
73   vgetq_lane_u8(v16, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}}
74   vgetq_lane_u8(v16, 0);
75   vgetq_lane_u8(v16, 15);
76   vgetq_lane_u8(v16, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
77 
78   vgetq_lane_u16(v8, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}}
79   vgetq_lane_u16(v8, 0);
80   vgetq_lane_u16(v8, 7);
81   vgetq_lane_u16(v8, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
82 
83   vgetq_lane_u32(v4, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
84   vgetq_lane_u32(v4, 0);
85   vgetq_lane_u32(v4, 3);
86   vgetq_lane_u32(v4, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
87 
88   vgetq_lane_u64(v2, -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
89   vgetq_lane_u64(v2, 0);
90   vgetq_lane_u64(v2, 1);
91   vgetq_lane_u64(v2, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
92 
93   vsetq_lane_u8(23, v16, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}}
94   vsetq_lane_u8(23, v16, 0);
95   vsetq_lane_u8(23, v16, 15);
96   vsetq_lane_u8(23, v16, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
97 
98   vsetq_lane_u16(23, v8, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}}
99   vsetq_lane_u16(23, v8, 0);
100   vsetq_lane_u16(23, v8, 7);
101   vsetq_lane_u16(23, v8, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
102 
103   vsetq_lane_u32(23, v4, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
104   vsetq_lane_u32(23, v4, 0);
105   vsetq_lane_u32(23, v4, 3);
106   vsetq_lane_u32(23, v4, 4); // expected-error {{argument value 4 is outside the valid range [0, 3]}}
107 
108   vsetq_lane_u64(23, v2, -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
109   vsetq_lane_u64(23, v2, 0);
110   vsetq_lane_u64(23, v2, 1);
111   vsetq_lane_u64(23, v2, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
112 }
113 
test_immediate_shifts(uint8x16_t vb,uint16x8_t vh,uint32x4_t vw)114 void test_immediate_shifts(uint8x16_t vb, uint16x8_t vh, uint32x4_t vw)
115 {
116   vshlq_n(vb, 0);
117   vshlq_n(vb, 7);
118   vshlq_n(vh, 0);
119   vshlq_n(vh, 15);
120   vshlq_n(vw, 0);
121   vshlq_n(vw, 31);
122 
123   vshlq_n(vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}}
124   vshlq_n(vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
125   vshlq_n(vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}}
126   vshlq_n(vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
127   vshlq_n(vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
128   vshlq_n(vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
129 
130   vqshlq_n(vb, 0);
131   vqshlq_n(vb, 7);
132   vqshlq_n(vh, 0);
133   vqshlq_n(vh, 15);
134   vqshlq_n(vw, 0);
135   vqshlq_n(vw, 31);
136 
137   vqshlq_n(vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}}
138   vqshlq_n(vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
139   vqshlq_n(vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}}
140   vqshlq_n(vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
141   vqshlq_n(vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
142   vqshlq_n(vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
143 
144   vsliq(vb, vb, 0);
145   vsliq(vb, vb, 7);
146   vsliq(vh, vh, 0);
147   vsliq(vh, vh, 15);
148   vsliq(vw, vw, 0);
149   vsliq(vw, vw, 31);
150 
151   vsliq(vb, vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}}
152   vsliq(vb, vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
153   vsliq(vh, vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}}
154   vsliq(vh, vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
155   vsliq(vw, vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}}
156   vsliq(vw, vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
157 
158   vshllbq(vb, 1);
159   vshllbq(vb, 8);
160   vshllbq(vh, 1);
161   vshllbq(vh, 16);
162 
163   vshllbq(vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}}
164   vshllbq(vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}}
165   vshllbq(vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}}
166   vshllbq(vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
167 
168   vshrq(vb, 1);
169   vshrq(vb, 8);
170   vshrq(vh, 1);
171   vshrq(vh, 16);
172   vshrq(vw, 1);
173   vshrq(vw, 32);
174 
175   vshrq(vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}}
176   vshrq(vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}}
177   vshrq(vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}}
178   vshrq(vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
179   vshrq(vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 32]}}
180   vshrq(vw, 33); // expected-error {{argument value 33 is outside the valid range [1, 32]}}
181 
182   vshrntq(vb, vh, 1);
183   vshrntq(vb, vh, 8);
184   vshrntq(vh, vw, 1);
185   vshrntq(vh, vw, 16);
186 
187   vshrntq(vb, vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}}
188   vshrntq(vb, vh, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}}
189   vshrntq(vh, vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}}
190   vshrntq(vh, vw, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
191 
192   vsriq(vb, vb, 1);
193   vsriq(vb, vb, 8);
194   vsriq(vh, vh, 1);
195   vsriq(vh, vh, 16);
196   vsriq(vw, vw, 1);
197   vsriq(vw, vw, 32);
198 
199   vsriq(vb, vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}}
200   vsriq(vb, vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}}
201   vsriq(vh, vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}}
202   vsriq(vh, vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
203   vsriq(vw, vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 32]}}
204   vsriq(vw, vw, 33); // expected-error {{argument value 33 is outside the valid range [1, 32]}}
205 }
206 
test_simd_bic_orr(int16x8_t h,int32x4_t w)207 void test_simd_bic_orr(int16x8_t h, int32x4_t w)
208 {
209     h = vbicq(h, 0x0000);
210     h = vbicq(h, 0x0001);
211     h = vbicq(h, 0x00FF);
212     h = vbicq(h, 0x0100);
213     h = vbicq(h, 0x0101); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
214     h = vbicq(h, 0x01FF); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
215     h = vbicq(h, 0xFF00);
216 
217     w = vbicq(w, 0x00000000);
218     w = vbicq(w, 0x00000001);
219     w = vbicq(w, 0x000000FF);
220     w = vbicq(w, 0x00000100);
221     w = vbicq(w, 0x0000FF00);
222     w = vbicq(w, 0x00010000);
223     w = vbicq(w, 0x00FF0000);
224     w = vbicq(w, 0x01000000);
225     w = vbicq(w, 0xFF000000);
226     w = vbicq(w, 0x01000001); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
227     w = vbicq(w, 0x01FFFFFF); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
228 
229     h = vorrq(h, 0x0000);
230     h = vorrq(h, 0x0001);
231     h = vorrq(h, 0x00FF);
232     h = vorrq(h, 0x0100);
233     h = vorrq(h, 0x0101); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
234     h = vorrq(h, 0x01FF); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
235     h = vorrq(h, 0xFF00);
236 
237     w = vorrq(w, 0x00000000);
238     w = vorrq(w, 0x00000001);
239     w = vorrq(w, 0x000000FF);
240     w = vorrq(w, 0x00000100);
241     w = vorrq(w, 0x0000FF00);
242     w = vorrq(w, 0x00010000);
243     w = vorrq(w, 0x00FF0000);
244     w = vorrq(w, 0x01000000);
245     w = vorrq(w, 0xFF000000);
246     w = vorrq(w, 0x01000001); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
247     w = vorrq(w, 0x01FFFFFF); // expected-error-re {{argument should be an 8-bit value shifted by a multiple of 8 bits{{$}}}}
248 }
249 
test_simd_vmvn(void)250 void test_simd_vmvn(void)
251 {
252     uint16x8_t h;
253     h = vmvnq_n_u16(0x0000);
254     h = vmvnq_n_u16(0x0001);
255     h = vmvnq_n_u16(0x00FF);
256     h = vmvnq_n_u16(0x0100);
257     h = vmvnq_n_u16(0x0101); // expected-error {{argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF}}
258     h = vmvnq_n_u16(0x01FF);
259     h = vmvnq_n_u16(0xFF00);
260 
261     uint32x4_t w;
262     w = vmvnq_n_u32(0x00000000);
263     w = vmvnq_n_u32(0x00000001);
264     w = vmvnq_n_u32(0x000000FF);
265     w = vmvnq_n_u32(0x00000100);
266     w = vmvnq_n_u32(0x0000FF00);
267     w = vmvnq_n_u32(0x00010000);
268     w = vmvnq_n_u32(0x00FF0000);
269     w = vmvnq_n_u32(0x01000000);
270     w = vmvnq_n_u32(0xFF000000);
271     w = vmvnq_n_u32(0x01000001); // expected-error {{argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF}}
272     w = vmvnq_n_u32(0x01FFFFFF); // expected-error {{argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF}}
273     w = vmvnq_n_u32(0x0001FFFF); // expected-error {{argument should be an 8-bit value shifted by a multiple of 8 bits, or in the form 0x??FF}}
274     w = vmvnq_n_u32(0x000001FF);
275 }
276 
test_vidup(void)277 void test_vidup(void)
278 {
279     vidupq_n_u16(0x12345678, 1);
280     vidupq_n_u16(0x12345678, 2);
281     vidupq_n_u16(0x12345678, 4);
282     vidupq_n_u16(0x12345678, 8);
283 
284     vidupq_n_u16(0x12345678, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}}
285     vidupq_n_u16(0x12345678, 16); // expected-error {{argument value 16 is outside the valid range [1, 8]}}
286     vidupq_n_u16(0x12345678, -1); // expected-error {{argument value -1 is outside the valid range [1, 8]}}
287     vidupq_n_u16(0x12345678, -2); // expected-error {{argument value -2 is outside the valid range [1, 8]}}
288     vidupq_n_u16(0x12345678, -4); // expected-error {{argument value -4 is outside the valid range [1, 8]}}
289     vidupq_n_u16(0x12345678, -8); // expected-error {{argument value -8 is outside the valid range [1, 8]}}
290     vidupq_n_u16(0x12345678, 3); // expected-error {{argument should be a power of 2}}
291     vidupq_n_u16(0x12345678, 7); // expected-error {{argument should be a power of 2}}
292 }
293 
test_vcvtq(void)294 void test_vcvtq(void)
295 {
296     uint16x8_t vec_u16;
297     float16x8_t vec_f16;
298     vcvtq_n_f16_u16(vec_u16, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}}
299     vcvtq_n_f16_u16(vec_u16, 1);
300     vcvtq_n_f16_u16(vec_u16, 16);
301     vcvtq_n_f16_u16(vec_u16, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}}
302 
303     int32x4_t vec_s32;
304     float32x4_t vec_f32;
305     vcvtq_n_s32_f32(vec_s32, -1); // expected-error {{argument value -1 is outside the valid range [1, 32]}}
306     vcvtq_n_s32_f32(vec_s32, 1);
307     vcvtq_n_s32_f32(vec_s32, 32);
308     vcvtq_n_s32_f32(vec_s32, 33); // expected-error {{argument value 33 is outside the valid range [1, 32]}}
309 }
310