1 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2 ; RUN: verify-uselistorder %s
4 @addr = external global i64
5 @addr_as1 = external addrspace(1) global i64
7 define i64 @add_unsigned(i64 %x, i64 %y) {
8 ; CHECK: %z = add nuw i64 %x, %y
9 %z = add nuw i64 %x, %y
13 define i64 @sub_unsigned(i64 %x, i64 %y) {
14 ; CHECK: %z = sub nuw i64 %x, %y
15 %z = sub nuw i64 %x, %y
19 define i64 @mul_unsigned(i64 %x, i64 %y) {
20 ; CHECK: %z = mul nuw i64 %x, %y
21 %z = mul nuw i64 %x, %y
25 define i64 @add_signed(i64 %x, i64 %y) {
26 ; CHECK: %z = add nsw i64 %x, %y
27 %z = add nsw i64 %x, %y
31 define i64 @sub_signed(i64 %x, i64 %y) {
32 ; CHECK: %z = sub nsw i64 %x, %y
33 %z = sub nsw i64 %x, %y
37 define i64 @mul_signed(i64 %x, i64 %y) {
38 ; CHECK: %z = mul nsw i64 %x, %y
39 %z = mul nsw i64 %x, %y
43 define i64 @add_plain(i64 %x, i64 %y) {
44 ; CHECK: %z = add i64 %x, %y
49 define i64 @sub_plain(i64 %x, i64 %y) {
50 ; CHECK: %z = sub i64 %x, %y
55 define i64 @mul_plain(i64 %x, i64 %y) {
56 ; CHECK: %z = mul i64 %x, %y
61 define i64 @add_both(i64 %x, i64 %y) {
62 ; CHECK: %z = add nuw nsw i64 %x, %y
63 %z = add nuw nsw i64 %x, %y
67 define i64 @sub_both(i64 %x, i64 %y) {
68 ; CHECK: %z = sub nuw nsw i64 %x, %y
69 %z = sub nuw nsw i64 %x, %y
73 define i64 @mul_both(i64 %x, i64 %y) {
74 ; CHECK: %z = mul nuw nsw i64 %x, %y
75 %z = mul nuw nsw i64 %x, %y
79 define 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
85 define 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
91 define 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
97 define i64 @shl_both(i64 %x, i64 %y) {
98 ; CHECK: %z = shl nuw nsw i64 %x, %y
99 %z = shl nuw nsw i64 %x, %y
103 define i64 @sdiv_exact(i64 %x, i64 %y) {
104 ; CHECK: %z = sdiv exact i64 %x, %y
105 %z = sdiv exact i64 %x, %y
109 define i64 @sdiv_plain(i64 %x, i64 %y) {
110 ; CHECK: %z = sdiv i64 %x, %y
115 define i64 @udiv_exact(i64 %x, i64 %y) {
116 ; CHECK: %z = udiv exact i64 %x, %y
117 %z = udiv exact i64 %x, %y
121 define i64 @udiv_plain(i64 %x, i64 %y) {
122 ; CHECK: %z = udiv i64 %x, %y
127 define i64 @ashr_plain(i64 %x, i64 %y) {
128 ; CHECK: %z = ashr i64 %x, %y
133 define i64 @ashr_exact(i64 %x, i64 %y) {
134 ; CHECK: %z = ashr exact i64 %x, %y
135 %z = ashr exact i64 %x, %y
139 define i64 @lshr_plain(i64 %x, i64 %y) {
140 ; CHECK: %z = lshr i64 %x, %y
145 define i64 @lshr_exact(i64 %x, i64 %y) {
146 ; CHECK: %z = lshr exact i64 %x, %y
147 %z = lshr exact i64 %x, %y
151 define 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
157 define ptr @gep_plain(ptr %p, i64 %x) {
158 ; CHECK: %z = getelementptr i64, ptr %p, i64 %x
159 %z = getelementptr i64, ptr %p, i64 %x
163 define i64 @add_both_ce() {
164 ; CHECK: ret i64 add nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
165 ret i64 add nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
168 define i64 @sub_both_ce() {
169 ; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
170 ret i64 sub nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
173 define i64 @mul_both_ce() {
174 ; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
175 ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
178 define ptr @gep_nw_ce() {
179 ; CHECK: ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)
180 ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)
183 define i64 @add_plain_ce() {
184 ; CHECK: ret i64 add (i64 ptrtoint (ptr @addr to i64), i64 91)
185 ret i64 add (i64 ptrtoint (ptr @addr to i64), i64 91)
188 define i64 @sub_plain_ce() {
189 ; CHECK: ret i64 sub (i64 ptrtoint (ptr @addr to i64), i64 91)
190 ret i64 sub (i64 ptrtoint (ptr @addr to i64), i64 91)
193 define i64 @mul_plain_ce() {
194 ; CHECK: ret i64 mul (i64 ptrtoint (ptr @addr to i64), i64 91)
195 ret i64 mul (i64 ptrtoint (ptr @addr to i64), i64 91)
198 define ptr @gep_plain_ce() {
199 ; CHECK: ret ptr getelementptr (i64, ptr @addr, i64 171)
200 ret ptr getelementptr (i64, ptr @addr, i64 171)
203 define i64 @add_both_reversed_ce() {
204 ; CHECK: ret i64 add nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
205 ret i64 add nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
208 define i64 @sub_both_reversed_ce() {
209 ; CHECK: ret i64 sub nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
210 ret i64 sub nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
213 define i64 @mul_both_reversed_ce() {
214 ; CHECK: ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
215 ret i64 mul nsw nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
218 define i64 @add_signed_ce() {
219 ; CHECK: ret i64 add nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
220 ret i64 add nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
223 define i64 @sub_signed_ce() {
224 ; CHECK: ret i64 sub nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
225 ret i64 sub nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
228 define i64 @mul_signed_ce() {
229 ; CHECK: ret i64 mul nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
230 ret i64 mul nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
233 define i64 @add_unsigned_ce() {
234 ; CHECK: ret i64 add nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
235 ret i64 add nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
238 define i64 @sub_unsigned_ce() {
239 ; CHECK: ret i64 sub nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
240 ret i64 sub nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
243 define i64 @mul_unsigned_ce() {
244 ; CHECK: ret i64 mul nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
245 ret i64 mul nuw (i64 ptrtoint (ptr @addr to i64), i64 91)
248 define i64 @test_zext(i32 %a) {
249 ; CHECK: %res = zext nneg i32 %a to i64
250 %res = zext nneg i32 %a to i64
254 define float @test_uitofp(i32 %a) {
255 ; CHECK: %res = uitofp nneg i32 %a to float
256 %res = uitofp nneg i32 %a to float
261 define i64 @test_or(i64 %a, i64 %b) {
262 ; CHECK: %res = or disjoint i64 %a, %b
263 %res = or disjoint i64 %a, %b
267 define i32 @test_trunc_signed(i64 %a) {
268 ; CHECK: %res = trunc nsw i64 %a to i32
269 %res = trunc nsw i64 %a to i32
273 define i32 @test_trunc_unsigned(i64 %a) {
274 ; CHECK: %res = trunc nuw i64 %a to i32
275 %res = trunc nuw i64 %a to i32
279 define 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
285 define 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
291 define <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>
297 define <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>
303 define <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>
309 define <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>
315 define 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
321 define 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
327 define 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
333 ; inbounds implies nusw, so the flag is not printed back.
334 define 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
340 define 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
346 define 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
352 define 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
358 define 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
361 ret ptr addrspace(1) %gep
364 define <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
370 define ptr @const_gep_nuw() {
371 ; CHECK: ret ptr getelementptr nuw (i8, ptr @addr, i64 100)
372 ret ptr getelementptr nuw (i8, ptr @addr, i64 100)
375 define ptr @const_gep_inbounds_nuw() {
376 ; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
377 ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
380 define ptr @const_gep_nusw() {
381 ; CHECK: ret ptr getelementptr nusw (i8, ptr @addr, i64 100)
382 ret ptr getelementptr nusw (i8, ptr @addr, i64 100)
385 ; inbounds implies nusw, so the flag is not printed back.
386 define ptr @const_gep_inbounds_nusw() {
387 ; CHECK: ret ptr getelementptr inbounds (i8, ptr @addr, i64 100)
388 ret ptr getelementptr inbounds nusw (i8, ptr @addr, i64 100)
391 define ptr @const_gep_nusw_nuw() {
392 ; CHECK: ret ptr getelementptr nusw nuw (i8, ptr @addr, i64 100)
393 ret ptr getelementptr nusw nuw (i8, ptr @addr, i64 100)
396 define ptr @const_gep_inbounds_nusw_nuw() {
397 ; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
398 ret ptr getelementptr inbounds nusw nuw (i8, ptr @addr, i64 100)
401 define ptr @const_gep_nuw_nusw_inbounds() {
402 ; CHECK: ret ptr getelementptr inbounds nuw (i8, ptr @addr, i64 100)
403 ret ptr getelementptr nuw nusw inbounds (i8, ptr @addr, i64 100)
406 define ptr @const_gep_nuw_inrange() {
407 ; CHECK: ret ptr getelementptr nuw inrange(-8, 16) (i8, ptr @addr, i64 100)
408 ret ptr getelementptr nuw inrange(-8, 16) (i8, ptr @addr, i64 100)
411 define 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)
413 ret ptr addrspace(1) getelementptr nusw nuw (i8, ptr addrspace(1) @addr_as1, i64 100)