llvm-project
414 строк · 10.8 Кб
1; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2; RUN: verify-uselistorder %s
3
4@addr = external global i64
5@addr_as1 = external addrspace(1) global i64
6
7define i64 @add_unsigned(i64 %x, i64 %y) {
8; CHECK: %z = add nuw i64 %x, %y
9%z = add nuw i64 %x, %y
10ret i64 %z
11}
12
13define i64 @sub_unsigned(i64 %x, i64 %y) {
14; CHECK: %z = sub nuw i64 %x, %y
15%z = sub nuw i64 %x, %y
16ret i64 %z
17}
18
19define i64 @mul_unsigned(i64 %x, i64 %y) {
20; CHECK: %z = mul nuw i64 %x, %y
21%z = mul nuw i64 %x, %y
22ret i64 %z
23}
24
25define i64 @add_signed(i64 %x, i64 %y) {
26; CHECK: %z = add nsw i64 %x, %y
27%z = add nsw i64 %x, %y
28ret i64 %z
29}
30
31define i64 @sub_signed(i64 %x, i64 %y) {
32; CHECK: %z = sub nsw i64 %x, %y
33%z = sub nsw i64 %x, %y
34ret i64 %z
35}
36
37define i64 @mul_signed(i64 %x, i64 %y) {
38; CHECK: %z = mul nsw i64 %x, %y
39%z = mul nsw i64 %x, %y
40ret i64 %z
41}
42
43define i64 @add_plain(i64 %x, i64 %y) {
44; CHECK: %z = add i64 %x, %y
45%z = add i64 %x, %y
46ret i64 %z
47}
48
49define i64 @sub_plain(i64 %x, i64 %y) {
50; CHECK: %z = sub i64 %x, %y
51%z = sub i64 %x, %y
52ret i64 %z
53}
54
55define i64 @mul_plain(i64 %x, i64 %y) {
56; CHECK: %z = mul i64 %x, %y
57%z = mul i64 %x, %y
58ret i64 %z
59}
60
61define i64 @add_both(i64 %x, i64 %y) {
62; CHECK: %z = add nuw nsw i64 %x, %y
63%z = add nuw nsw i64 %x, %y
64ret i64 %z
65}
66
67define i64 @sub_both(i64 %x, i64 %y) {
68; CHECK: %z = sub nuw nsw i64 %x, %y
69%z = sub nuw nsw i64 %x, %y
70ret i64 %z
71}
72
73define i64 @mul_both(i64 %x, i64 %y) {
74; CHECK: %z = mul nuw nsw i64 %x, %y
75%z = mul nuw nsw i64 %x, %y
76ret i64 %z
77}
78
79define i64 @add_both_reversed(i64 %x, i64 %y) {
80; CHECK: %z = add nuw nsw i64 %x, %y
81%z = add nsw nuw i64 %x, %y
82ret i64 %z
83}
84
85define i64 @sub_both_reversed(i64 %x, i64 %y) {
86; CHECK: %z = sub nuw nsw i64 %x, %y
87%z = sub nsw nuw i64 %x, %y
88ret i64 %z
89}
90
91define i64 @mul_both_reversed(i64 %x, i64 %y) {
92; CHECK: %z = mul nuw nsw i64 %x, %y
93%z = mul nsw nuw i64 %x, %y
94ret i64 %z
95}
96
97define i64 @shl_both(i64 %x, i64 %y) {
98; CHECK: %z = shl nuw nsw i64 %x, %y
99%z = shl nuw nsw i64 %x, %y
100ret i64 %z
101}
102
103define i64 @sdiv_exact(i64 %x, i64 %y) {
104; CHECK: %z = sdiv exact i64 %x, %y
105%z = sdiv exact i64 %x, %y
106ret i64 %z
107}
108
109define i64 @sdiv_plain(i64 %x, i64 %y) {
110; CHECK: %z = sdiv i64 %x, %y
111%z = sdiv i64 %x, %y
112ret i64 %z
113}
114
115define i64 @udiv_exact(i64 %x, i64 %y) {
116; CHECK: %z = udiv exact i64 %x, %y
117%z = udiv exact i64 %x, %y
118ret i64 %z
119}
120
121define i64 @udiv_plain(i64 %x, i64 %y) {
122; CHECK: %z = udiv i64 %x, %y
123%z = udiv i64 %x, %y
124ret i64 %z
125}
126
127define i64 @ashr_plain(i64 %x, i64 %y) {
128; CHECK: %z = ashr i64 %x, %y
129%z = ashr i64 %x, %y
130ret i64 %z
131}
132
133define i64 @ashr_exact(i64 %x, i64 %y) {
134; CHECK: %z = ashr exact i64 %x, %y
135%z = ashr exact i64 %x, %y
136ret i64 %z
137}
138
139define i64 @lshr_plain(i64 %x, i64 %y) {
140; CHECK: %z = lshr i64 %x, %y
141%z = lshr i64 %x, %y
142ret i64 %z
143}
144
145define i64 @lshr_exact(i64 %x, i64 %y) {
146; CHECK: %z = lshr exact i64 %x, %y
147%z = lshr exact i64 %x, %y
148ret i64 %z
149}
150
151define ptr @gep_nw(ptr %p, i64 %x) {
152; CHECK: %z = getelementptr inbounds i64, ptr %p, i64 %x
153%z = getelementptr inbounds i64, ptr %p, i64 %x
154ret ptr %z
155}
156
157define ptr @gep_plain(ptr %p, i64 %x) {
158; CHECK: %z = getelementptr i64, ptr %p, i64 %x
159%z = getelementptr i64, ptr %p, i64 %x
160ret ptr %z
161}
162
163define i64 @add_both_ce() {
164; CHECK: ret i64 add nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
165ret i64 add nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
166}
167
168define i64 @sub_both_ce() {
169; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
170ret i64 sub nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
171}
172
173define i64 @mul_both_ce() {
174; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
175ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
176}
177
178define ptr @gep_nw_ce() {
179; CHECK: ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)
180ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)
181}
182
183define i64 @add_plain_ce() {
184; CHECK: ret i64 add (i64 ptrtoint (ptr @addr to i64), i64 91)
185ret i64 add (i64 ptrtoint (ptr @addr to i64), i64 91)
186}
187
188define i64 @sub_plain_ce() {
189; CHECK: ret i64 sub (i64 ptrtoint (ptr @addr to i64), i64 91)
190ret i64 sub (i64 ptrtoint (ptr @addr to i64), i64 91)
191}
192
193define i64 @mul_plain_ce() {
194; CHECK: ret i64 mul (i64 ptrtoint (ptr @addr to i64), i64 91)
195ret i64 mul (i64 ptrtoint (ptr @addr to i64), i64 91)
196}
197
198define ptr @gep_plain_ce() {
199; CHECK: ret ptr getelementptr (i64, ptr @addr, i64 171)
200ret ptr getelementptr (i64, ptr @addr, i64 171)
201}
202
203define i64 @add_both_reversed_ce() {
204; CHECK: ret i64 add nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
205ret i64 add nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
206}
207
208define i64 @sub_both_reversed_ce() {
209; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
210ret i64 sub nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
211}
212
213define i64 @mul_both_reversed_ce() {
214; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
215ret i64 mul nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
216}
217
218define i64 @add_signed_ce() {
219; CHECK: ret i64 add nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
220ret i64 add nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
221}
222
223define i64 @sub_signed_ce() {
224; CHECK: ret i64 sub nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
225ret i64 sub nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
226}
227
228define i64 @mul_signed_ce() {
229; CHECK: ret i64 mul nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
230ret i64 mul nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
231}
232
233define i64 @add_unsigned_ce() {
234; CHECK: ret i64 add nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
235ret i64 add nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
236}
237
238define i64 @sub_unsigned_ce() {
239; CHECK: ret i64 sub nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
240ret i64 sub nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
241}
242
243define i64 @mul_unsigned_ce() {
244; CHECK: ret i64 mul nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
245ret i64 mul nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
246}
247
248define i64 @test_zext(i32 %a) {
249; CHECK: %res = zext nneg i32 %a to i64
250%res = zext nneg i32 %a to i64
251ret i64 %res
252}
253
254define float @test_uitofp(i32 %a) {
255; CHECK: %res = uitofp nneg i32 %a to float
256%res = uitofp nneg i32 %a to float
257ret float %res
258}
259
260
261define i64 @test_or(i64 %a, i64 %b) {
262; CHECK: %res = or disjoint i64 %a, %b
263%res = or disjoint i64 %a, %b
264ret i64 %res
265}
266
267define i32 @test_trunc_signed(i64 %a) {
268; CHECK: %res = trunc nsw i64 %a to i32
269%res = trunc nsw i64 %a to i32
270ret i32 %res
271}
272
273define i32 @test_trunc_unsigned(i64 %a) {
274; CHECK: %res = trunc nuw i64 %a to i32
275%res = trunc nuw i64 %a to i32
276ret i32 %res
277}
278
279define i32 @test_trunc_both(i64 %a) {
280; CHECK: %res = trunc nuw nsw i64 %a to i32
281%res = trunc nuw nsw i64 %a to i32
282ret i32 %res
283}
284
285define i32 @test_trunc_both_reversed(i64 %a) {
286; CHECK: %res = trunc nuw nsw i64 %a to i32
287%res = trunc nsw nuw i64 %a to i32
288ret i32 %res
289}
290
291define <2 x i32> @test_trunc_signed_vector(<2 x i64> %a) {
292; CHECK: %res = trunc nsw <2 x i64> %a to <2 x i32>
293%res = trunc nsw <2 x i64> %a to <2 x i32>
294ret <2 x i32> %res
295}
296
297define <2 x i32> @test_trunc_unsigned_vector(<2 x i64> %a) {
298; CHECK: %res = trunc nuw <2 x i64> %a to <2 x i32>
299%res = trunc nuw <2 x i64> %a to <2 x i32>
300ret <2 x i32> %res
301}
302
303define <2 x i32> @test_trunc_both_vector(<2 x i64> %a) {
304; CHECK: %res = trunc nuw nsw <2 x i64> %a to <2 x i32>
305%res = trunc nuw nsw <2 x i64> %a to <2 x i32>
306ret <2 x i32> %res
307}
308
309define <2 x i32> @test_trunc_both_reversed_vector(<2 x i64> %a) {
310; CHECK: %res = trunc nuw nsw <2 x i64> %a to <2 x i32>
311%res = trunc nsw nuw <2 x i64> %a to <2 x i32>
312ret <2 x i32> %res
313}
314
315define ptr @gep_nuw(ptr %p, i64 %idx) {
316; CHECK: %gep = getelementptr nuw i8, ptr %p, i64 %idx
317%gep = getelementptr nuw i8, ptr %p, i64 %idx
318ret ptr %gep
319}
320
321define ptr @gep_inbounds_nuw(ptr %p, i64 %idx) {
322; CHECK: %gep = getelementptr inbounds nuw i8, ptr %p, i64 %idx
323%gep = getelementptr inbounds nuw i8, ptr %p, i64 %idx
324ret ptr %gep
325}
326
327define ptr @gep_nusw(ptr %p, i64 %idx) {
328; CHECK: %gep = getelementptr nusw i8, ptr %p, i64 %idx
329%gep = getelementptr nusw i8, ptr %p, i64 %idx
330ret ptr %gep
331}
332
333; inbounds implies nusw, so the flag is not printed back.
334define ptr @gep_inbounds_nusw(ptr %p, i64 %idx) {
335; CHECK: %gep = getelementptr inbounds i8, ptr %p, i64 %idx
336%gep = getelementptr inbounds nusw i8, ptr %p, i64 %idx
337ret ptr %gep
338}
339
340define ptr @gep_nusw_nuw(ptr %p, i64 %idx) {
341; CHECK: %gep = getelementptr nusw nuw i8, ptr %p, i64 %idx
342%gep = getelementptr nusw nuw i8, ptr %p, i64 %idx
343ret ptr %gep
344}
345
346define ptr @gep_inbounds_nusw_nuw(ptr %p, i64 %idx) {
347; CHECK: %gep = getelementptr inbounds nuw i8, ptr %p, i64 %idx
348%gep = getelementptr inbounds nusw nuw i8, ptr %p, i64 %idx
349ret ptr %gep
350}
351
352define ptr @gep_nuw_nusw_inbounds(ptr %p, i64 %idx) {
353; CHECK: %gep = getelementptr inbounds nuw i8, ptr %p, i64 %idx
354%gep = getelementptr nuw nusw inbounds i8, ptr %p, i64 %idx
355ret ptr %gep
356}
357
358define ptr addrspace(1) @gep_nusw_nuw_as1(ptr addrspace(1) %p, i64 %idx) {
359; CHECK: %gep = getelementptr nusw nuw i8, ptr addrspace(1) %p, i64 %idx
360%gep = getelementptr nusw nuw i8, ptr addrspace(1) %p, i64 %idx
361ret ptr addrspace(1) %gep
362}
363
364define <2 x ptr> @gep_nusw_nuw_vec(<2 x ptr> %p, i64 %idx) {
365; CHECK: %gep = getelementptr nusw nuw i8, <2 x ptr> %p, i64 %idx
366%gep = getelementptr nusw nuw i8, <2 x ptr> %p, i64 %idx
367ret <2 x ptr> %gep
368}
369
370define ptr @const_gep_nuw() {
371; CHECK: ret ptr getelementptr nuw (i8, ptr @addr, i64 100)
372ret ptr getelementptr nuw (i8, ptr @addr, i64 100)
373}
374
375define ptr @const_gep_inbounds_nuw() {
376; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
377ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
378}
379
380define ptr @const_gep_nusw() {
381; CHECK: ret ptr getelementptr nusw (i8, ptr @addr, i64 100)
382ret ptr getelementptr nusw (i8, ptr @addr, i64 100)
383}
384
385; inbounds implies nusw, so the flag is not printed back.
386define ptr @const_gep_inbounds_nusw() {
387; CHECK: ret ptr getelementptr inbounds (i8, ptr @addr, i64 100)
388ret ptr getelementptr inbounds nusw (i8, ptr @addr, i64 100)
389}
390
391define ptr @const_gep_nusw_nuw() {
392; CHECK: ret ptr getelementptr nusw nuw (i8, ptr @addr, i64 100)
393ret ptr getelementptr nusw nuw (i8, ptr @addr, i64 100)
394}
395
396define ptr @const_gep_inbounds_nusw_nuw() {
397; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
398ret ptr getelementptr inbounds nusw nuw (i8, ptr @addr, i64 100)
399}
400
401define ptr @const_gep_nuw_nusw_inbounds() {
402; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
403ret ptr getelementptr nuw nusw inbounds (i8, ptr @addr, i64 100)
404}
405
406define ptr @const_gep_nuw_inrange() {
407; CHECK: ret ptr getelementptr nuw inrange(-8, 16) (i8, ptr @addr, i64 100)
408ret ptr getelementptr nuw inrange(-8, 16) (i8, ptr @addr, i64 100)
409}
410
411define ptr addrspace(1) @const_gep_nusw_nuw_as1() {
412; CHECK: ret ptr addrspace(1) getelementptr nusw nuw (i8, ptr addrspace(1) @addr_as1, i64 100)
413ret ptr addrspace(1) getelementptr nusw nuw (i8, ptr addrspace(1) @addr_as1, i64 100)
414}
415