1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2 ; RUN: opt < %s -S -passes=openmp-opt | FileCheck %s --check-prefixes=CHECK,MODULE
3 ; RUN: opt < %s -S -passes=openmp-opt-cgscc | FileCheck %s --check-prefixes=CHECK,CGSCC
4 ; REQUIRES: amdgpu-registered-target
6 target triple = "amdgcn-amd-amdhsa"
8 declare void @useI32(i32)
9 declare void @unknown()
10 declare void @aligned_barrier() "llvm.assume"="ompx_aligned_barrier"
11 declare void @llvm.nvvm.barrier0()
12 declare i32 @llvm.nvvm.barrier0.and(i32)
13 declare i32 @llvm.nvvm.barrier0.or(i32)
14 declare i32 @llvm.nvvm.barrier0.popc(i32)
15 declare void @llvm.amdgcn.s.barrier()
16 declare void @llvm.assume(i1)
19 ; CHECK: @[[GC1:[a-zA-Z0-9_$"\\.-]+]] = constant i32 42
20 ; CHECK: @[[GC2:[a-zA-Z0-9_$"\\.-]+]] = addrspace(4) global i32 0
21 ; CHECK: @[[GPTR4:[a-zA-Z0-9_$"\\.-]+]] = addrspace(4) global ptr addrspace(4) null
22 ; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = global i32 42
23 ; CHECK: @[[GS:[a-zA-Z0-9_$"\\.-]+]] = addrspace(3) global i32 0
24 ; CHECK: @[[GPTR:[a-zA-Z0-9_$"\\.-]+]] = global ptr null
25 ; CHECK: @[[PG1:[a-zA-Z0-9_$"\\.-]+]] = thread_local global i32 42
26 ; CHECK: @[[PG2:[a-zA-Z0-9_$"\\.-]+]] = addrspace(5) global i32 0
27 ; CHECK: @[[GPTR5:[a-zA-Z0-9_$"\\.-]+]] = global ptr addrspace(5) null
28 ; CHECK: @[[G1:[a-zA-Z0-9_$"\\.-]+]] = global i32 42
29 ; CHECK: @[[G2:[a-zA-Z0-9_$"\\.-]+]] = addrspace(1) global i32 0
31 define void @pos_empty_1(i1 %c) "kernel" {
32 ; MODULE-LABEL: define {{[^@]+}}@pos_empty_1
33 ; MODULE-SAME: (i1 [[C:%.*]]) #[[ATTR4:[0-9]+]] {
34 ; MODULE-NEXT: ret void
36 ; CGSCC-LABEL: define {{[^@]+}}@pos_empty_1
37 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR4:[0-9]+]] {
38 ; CGSCC-NEXT: call void @llvm.assume(i1 [[C]])
39 ; CGSCC-NEXT: call void @unknown() #[[ATTR0:[0-9]+]]
40 ; CGSCC-NEXT: call void @llvm.assume(i1 [[C]])
41 ; CGSCC-NEXT: ret void
43 call void @llvm.assume(i1 %c)
44 call void @unknown() "llvm.assume"="ompx_aligned_barrier"
45 call void @llvm.assume(i1 %c)
48 define void @pos_empty_2() "kernel" {
49 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_2
50 ; CHECK-SAME: () #[[ATTR4:[0-9]+]] {
51 ; CHECK-NEXT: ret void
53 call void @aligned_barrier()
56 define void @pos_empty_3() "kernel" {
57 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_3
58 ; CHECK-SAME: () #[[ATTR4]] {
59 ; CHECK-NEXT: ret void
61 call void @llvm.nvvm.barrier0()
64 define void @pos_empty_4() "kernel" {
65 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_4
66 ; CHECK-SAME: () #[[ATTR4]] {
67 ; CHECK-NEXT: ret void
69 call i32 @llvm.nvvm.barrier0.and(i32 0)
72 define void @pos_empty_5() "kernel" {
73 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_5
74 ; CHECK-SAME: () #[[ATTR4]] {
75 ; CHECK-NEXT: ret void
77 call i32 @llvm.nvvm.barrier0.or(i32 0)
80 define void @pos_empty_6() "kernel" {
81 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_6
82 ; CHECK-SAME: () #[[ATTR4]] {
83 ; CHECK-NEXT: ret void
85 call i32 @llvm.nvvm.barrier0.popc(i32 0)
88 define void @pos_empty_7a() "kernel" {
89 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_7a
90 ; CHECK-SAME: () #[[ATTR4]] {
91 ; CHECK-NEXT: call void @unknown()
92 ; CHECK-NEXT: ret void
94 call void @llvm.amdgcn.s.barrier()
98 ; FIXME: We should remove the barrier.
99 define void @pos_empty_7b() "kernel" {
100 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_7b
101 ; CHECK-SAME: () #[[ATTR4]] {
102 ; CHECK-NEXT: call void @unknown() #[[ATTR5:[0-9]+]]
103 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
104 ; CHECK-NEXT: call void @unknown()
105 ; CHECK-NEXT: ret void
107 call void @unknown() nosync readnone
108 call void @llvm.amdgcn.s.barrier()
112 define void @pos_empty_8(i1 %c) "kernel" {
113 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_8
114 ; CHECK-SAME: (i1 [[C:%.*]]) #[[ATTR4]] {
115 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
117 ; CHECK-NEXT: br label [[F]]
119 ; CHECK-NEXT: ret void
121 br i1 %c, label %t, label %f
124 call void @llvm.amdgcn.s.barrier() "llvm.assume"="ompx_aligned_barrier"
129 define void @neg_empty_8() "kernel" {
130 ; CHECK-LABEL: define {{[^@]+}}@neg_empty_8
131 ; CHECK-SAME: () #[[ATTR4]] {
132 ; CHECK-NEXT: call void @unknown()
133 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
134 ; CHECK-NEXT: ret void
137 call void @llvm.amdgcn.s.barrier()
140 define void @neg_empty_9(i1 %c) "kernel" {
141 ; CHECK-LABEL: define {{[^@]+}}@neg_empty_9
142 ; CHECK-SAME: (i1 [[C:%.*]]) #[[ATTR4]] {
143 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
145 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
146 ; CHECK-NEXT: fence release
147 ; CHECK-NEXT: br label [[M:%.*]]
149 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
150 ; CHECK-NEXT: fence release
151 ; CHECK-NEXT: br label [[M]]
153 ; CHECK-NEXT: fence release
154 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
155 ; CHECK-NEXT: fence release
156 ; CHECK-NEXT: ret void
158 br i1 %c, label %t, label %f
161 call void @llvm.amdgcn.s.barrier()
166 call void @llvm.amdgcn.s.barrier()
171 call void @llvm.amdgcn.s.barrier()
175 ; FIXME: We should remove the barrier
176 define void @pos_empty_10() "kernel" {
177 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_10
178 ; CHECK-SAME: () #[[ATTR4]] {
179 ; CHECK-NEXT: br label [[M:%.*]]
181 ; CHECK-NEXT: call void @llvm.amdgcn.s.barrier()
182 ; CHECK-NEXT: ret void
186 call void @llvm.amdgcn.s.barrier()
189 define void @pos_empty_11() "kernel" {
190 ; CHECK-LABEL: define {{[^@]+}}@pos_empty_11
191 ; CHECK-SAME: () #[[ATTR4]] {
192 ; CHECK-NEXT: br label [[M:%.*]]
194 ; CHECK-NEXT: ret void
198 call void @aligned_barrier()
199 call void @llvm.amdgcn.s.barrier()
202 define void @empty() {
203 ; CHECK-LABEL: define {{[^@]+}}@empty() {
204 ; CHECK-NEXT: ret void
208 ; FIXME: We should remove the barrier in the end but not the first one.
209 define void @neg_empty_12(i1 %c) "kernel" {
210 ; MODULE-LABEL: define {{[^@]+}}@neg_empty_12
211 ; MODULE-SAME: (i1 [[C:%.*]]) #[[ATTR4]] {
212 ; MODULE-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
214 ; MODULE-NEXT: call void @llvm.amdgcn.s.barrier()
215 ; MODULE-NEXT: br label [[M:%.*]]
217 ; MODULE-NEXT: br label [[M]]
219 ; MODULE-NEXT: call void @llvm.amdgcn.s.barrier()
220 ; MODULE-NEXT: ret void
222 ; CGSCC-LABEL: define {{[^@]+}}@neg_empty_12
223 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR4]] {
224 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
226 ; CGSCC-NEXT: call void @empty()
227 ; CGSCC-NEXT: call void @llvm.amdgcn.s.barrier()
228 ; CGSCC-NEXT: br label [[M:%.*]]
230 ; CGSCC-NEXT: call void @empty()
231 ; CGSCC-NEXT: br label [[M]]
233 ; CGSCC-NEXT: call void @llvm.amdgcn.s.barrier()
234 ; CGSCC-NEXT: ret void
236 br i1 %c, label %t, label %f
239 call void @llvm.amdgcn.s.barrier()
245 call void @llvm.amdgcn.s.barrier()
248 define void @neg_empty_1() "kernel" {
249 ; CHECK-LABEL: define {{[^@]+}}@neg_empty_1
250 ; CHECK-SAME: () #[[ATTR4]] {
251 ; CHECK-NEXT: call void @unknown()
252 ; CHECK-NEXT: ret void
257 define void @neg_empty_2() "kernel" {
258 ; CHECK-LABEL: define {{[^@]+}}@neg_empty_2
259 ; CHECK-SAME: () #[[ATTR4]] {
260 ; CHECK-NEXT: ret void
262 call void @aligned_barrier()
266 @GC1 = constant i32 42
267 @GC2 = addrspace(4) global i32 0
268 @GPtr4 = addrspace(4) global ptr addrspace(4) null
269 define void @pos_constant_loads() "kernel" {
270 ; CHECK-LABEL: define {{[^@]+}}@pos_constant_loads
271 ; CHECK-SAME: () #[[ATTR4]] {
272 ; CHECK-NEXT: [[ARG:%.*]] = load ptr addrspace(4), ptr addrspacecast (ptr addrspace(4) @GPtr4 to ptr), align 8
273 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr addrspacecast (ptr addrspace(4) @GC2 to ptr), align 4
274 ; CHECK-NEXT: [[ARGC:%.*]] = addrspacecast ptr addrspace(4) [[ARG]] to ptr
275 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[ARGC]], align 4
276 ; CHECK-NEXT: [[D:%.*]] = add i32 42, [[B]]
277 ; CHECK-NEXT: [[E:%.*]] = add i32 [[D]], [[C]]
278 ; CHECK-NEXT: call void @useI32(i32 [[E]])
279 ; CHECK-NEXT: ret void
281 %GPtr4c = addrspacecast ptr addrspace(4) @GPtr4 to ptr
282 %arg = load ptr addrspace(4), ptr %GPtr4c
283 %a = load i32, ptr @GC1
284 call void @aligned_barrier()
285 %GC2c = addrspacecast ptr addrspace(4) @GC2 to ptr
286 %b = load i32, ptr %GC2c
287 call void @aligned_barrier()
288 %argc = addrspacecast ptr addrspace(4) %arg to ptr
289 %c = load i32, ptr %argc
290 call void @aligned_barrier()
293 call void @useI32(i32 %e)
297 @GS = addrspace(3) global i32 0
298 @GPtr = global ptr null
299 ; TODO: We could remove some of the barriers due to the lack of write effects.
300 define void @neg_loads() "kernel" {
301 ; CHECK-LABEL: define {{[^@]+}}@neg_loads
302 ; CHECK-SAME: () #[[ATTR4]] {
303 ; CHECK-NEXT: [[ARG:%.*]] = load ptr, ptr @GPtr, align 8
304 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr @G, align 4
305 ; CHECK-NEXT: call void @aligned_barrier()
306 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr addrspacecast (ptr addrspace(3) @GS to ptr), align 4
307 ; CHECK-NEXT: call void @aligned_barrier()
308 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[ARG]], align 4
309 ; CHECK-NEXT: call void @aligned_barrier()
310 ; CHECK-NEXT: [[D:%.*]] = add i32 [[A]], [[B]]
311 ; CHECK-NEXT: [[E:%.*]] = add i32 [[D]], [[C]]
312 ; CHECK-NEXT: call void @useI32(i32 [[E]])
313 ; CHECK-NEXT: ret void
315 %arg = load ptr, ptr @GPtr
316 %a = load i32, ptr @G
317 call void @aligned_barrier()
318 %GSc = addrspacecast ptr addrspace(3) @GS to ptr
319 %b = load i32, ptr %GSc
320 call void @aligned_barrier()
321 %c = load i32, ptr %arg
322 call void @aligned_barrier()
325 call void @useI32(i32 %e)
328 @PG1 = thread_local global i32 42
329 @PG2 = addrspace(5) global i32 0
330 @GPtr5 = global ptr addrspace(5) null
331 define void @pos_priv_mem() "kernel" {
332 ; CHECK-LABEL: define {{[^@]+}}@pos_priv_mem
333 ; CHECK-SAME: () #[[ATTR4]] {
334 ; CHECK-NEXT: [[ARG:%.*]] = load ptr addrspace(5), ptr @GPtr5, align 4
335 ; CHECK-NEXT: [[LOC:%.*]] = alloca i32, align 4
336 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr @PG1, align 4
337 ; CHECK-NEXT: store i32 [[A]], ptr [[LOC]], align 4
338 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr addrspacecast (ptr addrspace(5) @PG2 to ptr), align 4
339 ; CHECK-NEXT: [[ARGC:%.*]] = addrspacecast ptr addrspace(5) [[ARG]] to ptr
340 ; CHECK-NEXT: store i32 [[B]], ptr [[ARGC]], align 4
341 ; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[LOC]], align 4
342 ; CHECK-NEXT: store i32 [[V]], ptr @PG1, align 4
343 ; CHECK-NEXT: ret void
345 %arg = load ptr addrspace(5), ptr @GPtr5
347 %a = load i32, ptr @PG1
348 call void @aligned_barrier()
349 store i32 %a, ptr %loc
350 %PG2c = addrspacecast ptr addrspace(5) @PG2 to ptr
351 %b = load i32, ptr %PG2c
352 call void @aligned_barrier()
353 %argc = addrspacecast ptr addrspace(5) %arg to ptr
354 store i32 %b, ptr %argc
355 call void @aligned_barrier()
356 %v = load i32, ptr %loc
357 store i32 %v, ptr @PG1
358 call void @aligned_barrier()
362 @G2 = addrspace(1) global i32 0
363 define void @neg_mem() "kernel" {
364 ; CHECK-LABEL: define {{[^@]+}}@neg_mem
365 ; CHECK-SAME: () #[[ATTR4]] {
366 ; CHECK-NEXT: [[ARG:%.*]] = load ptr, ptr @GPtr, align 8
367 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr @G1, align 4
368 ; CHECK-NEXT: fence seq_cst
369 ; CHECK-NEXT: call void @aligned_barrier()
370 ; CHECK-NEXT: store i32 [[A]], ptr [[ARG]], align 4
371 ; CHECK-NEXT: fence release
372 ; CHECK-NEXT: call void @aligned_barrier()
373 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr addrspacecast (ptr addrspace(1) @G2 to ptr), align 4
374 ; CHECK-NEXT: store i32 [[B]], ptr @G1, align 4
375 ; CHECK-NEXT: fence acquire
376 ; CHECK-NEXT: ret void
378 %arg = load ptr, ptr @GPtr
379 %a = load i32, ptr @G1
381 call void @aligned_barrier()
382 store i32 %a, ptr %arg
384 call void @aligned_barrier()
385 %G2c = addrspacecast ptr addrspace(1) @G2 to ptr
386 %b = load i32, ptr %G2c
387 store i32 %b, ptr @G1
389 call void @aligned_barrier()
393 define void @pos_multiple() "kernel" {
394 ; CHECK-LABEL: define {{[^@]+}}@pos_multiple
395 ; CHECK-SAME: () #[[ATTR4]] {
396 ; CHECK-NEXT: ret void
398 call void @llvm.nvvm.barrier0()
399 call void @aligned_barrier()
400 call void @aligned_barrier()
401 call void @llvm.amdgcn.s.barrier()
402 call void @aligned_barrier()
403 call void @llvm.nvvm.barrier0()
404 call void @aligned_barrier()
405 call void @aligned_barrier()
409 define void @multiple_blocks_kernel_1(i1 %c0, i1 %c1) "kernel" {
410 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_kernel_1
411 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]]) #[[ATTR4]] {
412 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
414 ; CHECK-NEXT: br label [[T0B:%.*]]
416 ; CHECK-NEXT: br label [[M:%.*]]
418 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
420 ; CHECK-NEXT: br label [[M]]
422 ; CHECK-NEXT: br label [[M]]
424 ; CHECK-NEXT: ret void
427 call void @llvm.nvvm.barrier0()
429 call void @aligned_barrier()
431 br i1 %c0, label %t0, label %f0
434 call void @aligned_barrier()
439 call void @aligned_barrier()
444 call void @aligned_barrier()
446 call void @llvm.nvvm.barrier0()
448 br i1 %c1, label %t1, label %f1
451 call void @aligned_barrier()
456 call void @aligned_barrier()
461 call void @aligned_barrier()
466 define void @multiple_blocks_kernel_2(i1 %c0, i1 %c1, ptr %p) "kernel" {
467 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_kernel_2
468 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
469 ; CHECK-NEXT: store i32 4, ptr [[P]], align 4
470 ; CHECK-NEXT: call void @aligned_barrier()
471 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
473 ; CHECK-NEXT: br label [[T0B:%.*]]
475 ; CHECK-NEXT: br label [[M:%.*]]
477 ; CHECK-NEXT: store i32 4, ptr [[P]], align 4
478 ; CHECK-NEXT: call void @llvm.nvvm.barrier0()
479 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
481 ; CHECK-NEXT: br label [[M]]
483 ; CHECK-NEXT: br label [[M]]
485 ; CHECK-NEXT: store i32 4, ptr [[P]], align 4
486 ; CHECK-NEXT: ret void
488 call void @llvm.nvvm.barrier0()
490 call void @aligned_barrier()
491 br i1 %c0, label %t0, label %f0
493 call void @aligned_barrier()
496 call void @aligned_barrier()
499 call void @aligned_barrier()
501 call void @llvm.nvvm.barrier0()
502 br i1 %c1, label %t1, label %f1
504 call void @aligned_barrier()
507 call void @aligned_barrier()
511 call void @aligned_barrier()
515 define void @multiple_blocks_non_kernel_1(i1 %c0, i1 %c1) "kernel" {
516 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_non_kernel_1
517 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]]) #[[ATTR4]] {
518 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
520 ; CHECK-NEXT: br label [[T0B:%.*]]
522 ; CHECK-NEXT: br label [[M:%.*]]
524 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
526 ; CHECK-NEXT: br label [[M]]
528 ; CHECK-NEXT: br label [[M]]
530 ; CHECK-NEXT: ret void
532 call void @llvm.nvvm.barrier0()
533 call void @aligned_barrier()
534 br i1 %c0, label %t0, label %f0
536 call void @aligned_barrier()
539 call void @aligned_barrier()
542 call void @aligned_barrier()
543 call void @llvm.nvvm.barrier0()
544 br i1 %c1, label %t1, label %f1
546 call void @aligned_barrier()
549 call void @aligned_barrier()
552 call void @aligned_barrier()
556 define void @multiple_blocks_non_kernel_2(i1 %c0, i1 %c1) "kernel" {
557 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_non_kernel_2
558 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]]) #[[ATTR4]] {
559 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
561 ; CHECK-NEXT: br label [[T0B:%.*]]
563 ; CHECK-NEXT: br label [[M:%.*]]
565 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
567 ; CHECK-NEXT: br label [[M]]
569 ; CHECK-NEXT: br label [[M]]
571 ; CHECK-NEXT: ret void
573 br i1 %c0, label %t0, label %f0
575 call void @aligned_barrier()
578 call void @aligned_barrier()
581 call void @aligned_barrier()
582 call void @llvm.nvvm.barrier0()
583 br i1 %c1, label %t1, label %f1
585 call void @aligned_barrier()
588 call void @aligned_barrier()
591 call void @aligned_barrier()
595 define void @multiple_blocks_non_kernel_3(i1 %c0, i1 %c1) "kernel" {
596 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_non_kernel_3
597 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]]) #[[ATTR4]] {
598 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
600 ; CHECK-NEXT: br label [[T0B:%.*]]
602 ; CHECK-NEXT: br label [[M:%.*]]
604 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
606 ; CHECK-NEXT: br label [[M]]
608 ; CHECK-NEXT: br label [[M]]
610 ; CHECK-NEXT: ret void
612 br i1 %c0, label %t0, label %f0
618 call void @aligned_barrier()
619 call void @llvm.nvvm.barrier0()
620 br i1 %c1, label %t1, label %f1
622 call void @aligned_barrier()
625 call void @aligned_barrier()
628 call void @aligned_barrier()
632 define void @multiple_blocks_non_kernel_effects_1(i1 %c0, i1 %c1, ptr %p) "kernel" {
633 ; CHECK-LABEL: define {{[^@]+}}@multiple_blocks_non_kernel_effects_1
634 ; CHECK-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
635 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
636 ; CHECK-NEXT: call void @aligned_barrier()
637 ; CHECK-NEXT: br i1 [[C0]], label [[T0:%.*]], label [[F0:%.*]]
639 ; CHECK-NEXT: store i32 1, ptr [[P]], align 4
640 ; CHECK-NEXT: br label [[T0B:%.*]]
642 ; CHECK-NEXT: call void @aligned_barrier()
643 ; CHECK-NEXT: br label [[M:%.*]]
645 ; CHECK-NEXT: store i32 2, ptr [[P]], align 4
646 ; CHECK-NEXT: br i1 [[C1]], label [[T1:%.*]], label [[F1:%.*]]
648 ; CHECK-NEXT: call void @aligned_barrier()
649 ; CHECK-NEXT: br label [[M]]
651 ; CHECK-NEXT: call void @aligned_barrier()
652 ; CHECK-NEXT: br label [[M]]
654 ; CHECK-NEXT: store i32 3, ptr [[P]], align 4
655 ; CHECK-NEXT: ret void
657 call void @aligned_barrier()
659 call void @aligned_barrier()
660 br i1 %c0, label %t0, label %f0
662 call void @aligned_barrier()
666 call void @aligned_barrier()
669 call void @aligned_barrier()
670 call void @llvm.nvvm.barrier0()
672 br i1 %c1, label %t1, label %f1
674 call void @aligned_barrier()
677 call void @aligned_barrier()
680 call void @aligned_barrier()
682 call void @aligned_barrier()
686 define internal void @write_then_barrier0(ptr %p) {
687 ; CHECK-LABEL: define {{[^@]+}}@write_then_barrier0
688 ; CHECK-SAME: (ptr [[P:%.*]]) {
689 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
690 ; CHECK-NEXT: call void @aligned_barrier()
691 ; CHECK-NEXT: ret void
694 call void @aligned_barrier()
697 define internal void @barrier_then_write0(ptr %p) {
698 ; MODULE-LABEL: define {{[^@]+}}@barrier_then_write0
699 ; MODULE-SAME: (ptr [[P:%.*]]) {
700 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
701 ; MODULE-NEXT: ret void
703 ; CGSCC-LABEL: define {{[^@]+}}@barrier_then_write0
704 ; CGSCC-SAME: (ptr [[P:%.*]]) {
705 ; CGSCC-NEXT: call void @aligned_barrier()
706 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
707 ; CGSCC-NEXT: ret void
709 call void @aligned_barrier()
713 define internal void @barrier_then_write_then_barrier0(ptr %p) {
714 ; MODULE-LABEL: define {{[^@]+}}@barrier_then_write_then_barrier0
715 ; MODULE-SAME: (ptr [[P:%.*]]) {
716 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
717 ; MODULE-NEXT: call void @aligned_barrier()
718 ; MODULE-NEXT: ret void
720 ; CGSCC-LABEL: define {{[^@]+}}@barrier_then_write_then_barrier0
721 ; CGSCC-SAME: (ptr [[P:%.*]]) {
722 ; CGSCC-NEXT: call void @aligned_barrier()
723 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
724 ; CGSCC-NEXT: call void @aligned_barrier()
725 ; CGSCC-NEXT: ret void
727 call void @aligned_barrier()
729 call void @aligned_barrier()
732 define void @multiple_blocks_functions_kernel_effects_0(i1 %c0, i1 %c1, ptr %p) "kernel" {
733 ; MODULE-LABEL: define {{[^@]+}}@multiple_blocks_functions_kernel_effects_0
734 ; MODULE-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
735 ; MODULE-NEXT: call void @barrier_then_write_then_barrier0(ptr [[P]])
736 ; MODULE-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
738 ; MODULE-NEXT: call void @barrier_then_write0(ptr [[P]])
739 ; MODULE-NEXT: br label [[T0B3:%.*]]
741 ; MODULE-NEXT: br label [[M3:%.*]]
743 ; MODULE-NEXT: call void @barrier_then_write0(ptr [[P]])
744 ; MODULE-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
746 ; MODULE-NEXT: br label [[M3]]
748 ; MODULE-NEXT: br label [[M3]]
750 ; MODULE-NEXT: call void @write_then_barrier0(ptr [[P]])
751 ; MODULE-NEXT: ret void
753 ; CGSCC-LABEL: define {{[^@]+}}@multiple_blocks_functions_kernel_effects_0
754 ; CGSCC-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
755 ; CGSCC-NEXT: call void @barrier_then_write_then_barrier0(ptr [[P]])
756 ; CGSCC-NEXT: call void @aligned_barrier()
757 ; CGSCC-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
759 ; CGSCC-NEXT: call void @barrier_then_write0(ptr [[P]])
760 ; CGSCC-NEXT: br label [[T0B3:%.*]]
762 ; CGSCC-NEXT: call void @aligned_barrier()
763 ; CGSCC-NEXT: br label [[M3:%.*]]
765 ; CGSCC-NEXT: call void @barrier_then_write0(ptr [[P]])
766 ; CGSCC-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
768 ; CGSCC-NEXT: call void @aligned_barrier()
769 ; CGSCC-NEXT: br label [[M3]]
771 ; CGSCC-NEXT: call void @aligned_barrier()
772 ; CGSCC-NEXT: br label [[M3]]
774 ; CGSCC-NEXT: call void @write_then_barrier0(ptr [[P]])
775 ; CGSCC-NEXT: ret void
777 call void @barrier_then_write_then_barrier0(ptr %p)
778 call void @aligned_barrier()
779 br i1 %c0, label %t03, label %f03
781 call void @barrier_then_write0(ptr %p)
784 call void @aligned_barrier()
787 call void @aligned_barrier()
788 call void @barrier_then_write0(ptr %p)
789 br i1 %c1, label %t13, label %f13
791 call void @aligned_barrier()
794 call void @aligned_barrier()
797 call void @aligned_barrier()
798 call void @write_then_barrier0(ptr %p)
801 define internal void @write_then_barrier1(ptr %p) {
802 ; CHECK-LABEL: define {{[^@]+}}@write_then_barrier1
803 ; CHECK-SAME: (ptr [[P:%.*]]) {
804 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
805 ; CHECK-NEXT: call void @aligned_barrier()
806 ; CHECK-NEXT: ret void
809 call void @aligned_barrier()
812 define internal void @barrier_then_write1(ptr %p) {
813 ; MODULE-LABEL: define {{[^@]+}}@barrier_then_write1
814 ; MODULE-SAME: (ptr [[P:%.*]]) {
815 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
816 ; MODULE-NEXT: ret void
818 ; CGSCC-LABEL: define {{[^@]+}}@barrier_then_write1
819 ; CGSCC-SAME: (ptr [[P:%.*]]) {
820 ; CGSCC-NEXT: call void @aligned_barrier()
821 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
822 ; CGSCC-NEXT: ret void
824 call void @aligned_barrier()
828 define internal void @barrier_then_write_then_barrier1(ptr %p) {
829 ; CHECK-LABEL: define {{[^@]+}}@barrier_then_write_then_barrier1
830 ; CHECK-SAME: (ptr [[P:%.*]]) {
831 ; CHECK-NEXT: call void @aligned_barrier()
832 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
833 ; CHECK-NEXT: call void @aligned_barrier()
834 ; CHECK-NEXT: ret void
836 call void @aligned_barrier()
838 call void @aligned_barrier()
841 define void @multiple_blocks_functions_non_kernel_effects_1(i1 %c0, i1 %c1, ptr %p) {
842 ; MODULE-LABEL: define {{[^@]+}}@multiple_blocks_functions_non_kernel_effects_1
843 ; MODULE-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) {
844 ; MODULE-NEXT: call void @barrier_then_write_then_barrier1(ptr [[P]])
845 ; MODULE-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
847 ; MODULE-NEXT: call void @barrier_then_write1(ptr [[P]])
848 ; MODULE-NEXT: br label [[T0B3:%.*]]
850 ; MODULE-NEXT: call void @aligned_barrier()
851 ; MODULE-NEXT: br label [[M3:%.*]]
853 ; MODULE-NEXT: call void @barrier_then_write1(ptr [[P]])
854 ; MODULE-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
856 ; MODULE-NEXT: call void @aligned_barrier()
857 ; MODULE-NEXT: br label [[M3]]
859 ; MODULE-NEXT: call void @aligned_barrier()
860 ; MODULE-NEXT: br label [[M3]]
862 ; MODULE-NEXT: call void @write_then_barrier1(ptr [[P]])
863 ; MODULE-NEXT: ret void
865 ; CGSCC-LABEL: define {{[^@]+}}@multiple_blocks_functions_non_kernel_effects_1
866 ; CGSCC-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) {
867 ; CGSCC-NEXT: call void @barrier_then_write_then_barrier1(ptr [[P]])
868 ; CGSCC-NEXT: call void @aligned_barrier()
869 ; CGSCC-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
871 ; CGSCC-NEXT: call void @barrier_then_write1(ptr [[P]])
872 ; CGSCC-NEXT: br label [[T0B3:%.*]]
874 ; CGSCC-NEXT: call void @aligned_barrier()
875 ; CGSCC-NEXT: br label [[M3:%.*]]
877 ; CGSCC-NEXT: call void @barrier_then_write1(ptr [[P]])
878 ; CGSCC-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
880 ; CGSCC-NEXT: call void @aligned_barrier()
881 ; CGSCC-NEXT: br label [[M3]]
883 ; CGSCC-NEXT: call void @aligned_barrier()
884 ; CGSCC-NEXT: br label [[M3]]
886 ; CGSCC-NEXT: call void @write_then_barrier1(ptr [[P]])
887 ; CGSCC-NEXT: ret void
889 call void @barrier_then_write_then_barrier1(ptr %p)
890 call void @aligned_barrier()
891 br i1 %c0, label %t03, label %f03
893 call void @barrier_then_write1(ptr %p)
896 call void @aligned_barrier()
899 call void @aligned_barrier()
900 call void @barrier_then_write1(ptr %p)
901 br i1 %c1, label %t13, label %f13
903 call void @aligned_barrier()
906 call void @aligned_barrier()
909 call void @aligned_barrier()
910 call void @write_then_barrier1(ptr %p)
914 define internal void @write_then_barrier2(ptr %p) {
915 ; CHECK-LABEL: define {{[^@]+}}@write_then_barrier2
916 ; CHECK-SAME: (ptr [[P:%.*]]) {
917 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
918 ; CHECK-NEXT: call void @aligned_barrier()
919 ; CHECK-NEXT: ret void
922 call void @aligned_barrier()
925 define internal void @barrier_then_write2(ptr %p) {
926 ; CHECK-LABEL: define {{[^@]+}}@barrier_then_write2
927 ; CHECK-SAME: (ptr [[P:%.*]]) {
928 ; CHECK-NEXT: call void @aligned_barrier()
929 ; CHECK-NEXT: store i32 0, ptr [[P]], align 4
930 ; CHECK-NEXT: ret void
932 call void @aligned_barrier()
936 define internal void @barrier_then_write_then_barrier2(ptr %p) {
937 ; MODULE-LABEL: define {{[^@]+}}@barrier_then_write_then_barrier2
938 ; MODULE-SAME: (ptr [[P:%.*]]) {
939 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
940 ; MODULE-NEXT: call void @aligned_barrier()
941 ; MODULE-NEXT: ret void
943 ; CGSCC-LABEL: define {{[^@]+}}@barrier_then_write_then_barrier2
944 ; CGSCC-SAME: (ptr [[P:%.*]]) {
945 ; CGSCC-NEXT: call void @aligned_barrier()
946 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
947 ; CGSCC-NEXT: call void @aligned_barrier()
948 ; CGSCC-NEXT: ret void
950 call void @aligned_barrier()
952 call void @aligned_barrier()
955 define void @multiple_blocks_functions_non_kernel_effects_2(i1 %c0, i1 %c1, ptr %p) "kernel" {
956 ; MODULE-LABEL: define {{[^@]+}}@multiple_blocks_functions_non_kernel_effects_2
957 ; MODULE-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
958 ; MODULE-NEXT: call void @barrier_then_write_then_barrier2(ptr [[P]])
959 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
960 ; MODULE-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
962 ; MODULE-NEXT: call void @barrier_then_write2(ptr [[P]])
963 ; MODULE-NEXT: br label [[T0B3:%.*]]
965 ; MODULE-NEXT: call void @aligned_barrier()
966 ; MODULE-NEXT: br label [[M3:%.*]]
968 ; MODULE-NEXT: call void @aligned_barrier()
969 ; MODULE-NEXT: call void @barrier_then_write2(ptr [[P]])
970 ; MODULE-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
972 ; MODULE-NEXT: call void @aligned_barrier()
973 ; MODULE-NEXT: br label [[M3]]
975 ; MODULE-NEXT: call void @aligned_barrier()
976 ; MODULE-NEXT: br label [[M3]]
978 ; MODULE-NEXT: call void @write_then_barrier2(ptr [[P]])
979 ; MODULE-NEXT: store i32 0, ptr [[P]], align 4
980 ; MODULE-NEXT: ret void
982 ; CGSCC-LABEL: define {{[^@]+}}@multiple_blocks_functions_non_kernel_effects_2
983 ; CGSCC-SAME: (i1 [[C0:%.*]], i1 [[C1:%.*]], ptr [[P:%.*]]) #[[ATTR4]] {
984 ; CGSCC-NEXT: call void @barrier_then_write_then_barrier2(ptr [[P]])
985 ; CGSCC-NEXT: call void @aligned_barrier()
986 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
987 ; CGSCC-NEXT: br i1 [[C0]], label [[T03:%.*]], label [[F03:%.*]]
989 ; CGSCC-NEXT: call void @barrier_then_write2(ptr [[P]])
990 ; CGSCC-NEXT: br label [[T0B3:%.*]]
992 ; CGSCC-NEXT: call void @aligned_barrier()
993 ; CGSCC-NEXT: br label [[M3:%.*]]
995 ; CGSCC-NEXT: call void @aligned_barrier()
996 ; CGSCC-NEXT: call void @barrier_then_write2(ptr [[P]])
997 ; CGSCC-NEXT: br i1 [[C1]], label [[T13:%.*]], label [[F13:%.*]]
999 ; CGSCC-NEXT: call void @aligned_barrier()
1000 ; CGSCC-NEXT: br label [[M3]]
1002 ; CGSCC-NEXT: call void @aligned_barrier()
1003 ; CGSCC-NEXT: br label [[M3]]
1005 ; CGSCC-NEXT: call void @write_then_barrier2(ptr [[P]])
1006 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
1007 ; CGSCC-NEXT: ret void
1009 call void @barrier_then_write_then_barrier2(ptr %p)
1010 call void @aligned_barrier()
1012 br i1 %c0, label %t03, label %f03
1014 call void @barrier_then_write2(ptr %p)
1017 call void @aligned_barrier()
1020 call void @aligned_barrier()
1021 call void @barrier_then_write2(ptr %p)
1022 br i1 %c1, label %t13, label %f13
1024 call void @aligned_barrier()
1027 call void @aligned_barrier()
1030 call void @aligned_barrier()
1031 call void @write_then_barrier2(ptr %p)
1036 ; Verify we do not remove the barrier in the callee.
1037 define internal void @callee_barrier() {
1038 ; CHECK-LABEL: define {{[^@]+}}@callee_barrier() {
1039 ; CHECK-NEXT: call void @aligned_barrier()
1040 ; CHECK-NEXT: ret void
1042 call void @aligned_barrier()
1045 define void @caller_barrier1() "kernel" {
1046 ; CHECK-LABEL: define {{[^@]+}}@caller_barrier1
1047 ; CHECK-SAME: () #[[ATTR4]] {
1048 ; CHECK-NEXT: call void @callee_barrier()
1049 ; CHECK-NEXT: ret void
1051 call void @aligned_barrier()
1052 call void @callee_barrier()
1053 call void @aligned_barrier()
1056 define void @caller_barrier2() "kernel" {
1057 ; CHECK-LABEL: define {{[^@]+}}@caller_barrier2
1058 ; CHECK-SAME: () #[[ATTR4]] {
1059 ; CHECK-NEXT: call void @unknown()
1060 ; CHECK-NEXT: call void @callee_barrier()
1061 ; CHECK-NEXT: call void @unknown()
1062 ; CHECK-NEXT: ret void
1064 call void @unknown()
1065 call void @callee_barrier()
1066 call void @unknown()
1070 define void @loop_barrier() "kernel" {
1071 ; CHECK-LABEL: define {{[^@]+}}@loop_barrier
1072 ; CHECK-SAME: () #[[ATTR4]] {
1073 ; CHECK-NEXT: entry:
1074 ; CHECK-NEXT: br label [[LOOP:%.*]]
1076 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
1077 ; CHECK-NEXT: call void @unknown()
1078 ; CHECK-NEXT: call void @aligned_barrier()
1079 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
1080 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[I_NEXT]], 128
1081 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
1083 ; CHECK-NEXT: ret void
1089 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1090 call void @unknown()
1091 call void @aligned_barrier()
1092 %i.next = add nuw nsw i32 %i, 1
1093 %cond = icmp ne i32 %i.next, 128
1094 br i1 %cond, label %loop, label %exit
1100 define void @loop_barrier_end_barriers() "kernel" {
1101 ; CHECK-LABEL: define {{[^@]+}}@loop_barrier_end_barriers
1102 ; CHECK-SAME: () #[[ATTR4]] {
1103 ; CHECK-NEXT: entry:
1104 ; CHECK-NEXT: br label [[LOOP:%.*]]
1106 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
1107 ; CHECK-NEXT: call void @unknown()
1108 ; CHECK-NEXT: call void @aligned_barrier()
1109 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
1110 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[I_NEXT]], 128
1111 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
1113 ; CHECK-NEXT: ret void
1119 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1120 call void @unknown()
1121 call void @aligned_barrier()
1122 %i.next = add nuw nsw i32 %i, 1
1123 %cond = icmp ne i32 %i.next, 128
1124 br i1 %cond, label %loop, label %exit
1127 call void @aligned_barrier()
1128 call void @aligned_barrier()
1129 call void @aligned_barrier()
1130 call void @aligned_barrier()
1134 define void @loop_barrier_end_barriers_unknown() "kernel" {
1135 ; CHECK-LABEL: define {{[^@]+}}@loop_barrier_end_barriers_unknown
1136 ; CHECK-SAME: () #[[ATTR4]] {
1137 ; CHECK-NEXT: entry:
1138 ; CHECK-NEXT: br label [[LOOP:%.*]]
1140 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
1141 ; CHECK-NEXT: call void @unknown()
1142 ; CHECK-NEXT: call void @aligned_barrier()
1143 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
1144 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[I_NEXT]], 128
1145 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
1147 ; CHECK-NEXT: call void @unknown()
1148 ; CHECK-NEXT: ret void
1154 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1155 call void @unknown()
1156 call void @aligned_barrier()
1157 %i.next = add nuw nsw i32 %i, 1
1158 %cond = icmp ne i32 %i.next, 128
1159 br i1 %cond, label %loop, label %exit
1162 call void @aligned_barrier()
1163 call void @aligned_barrier()
1164 call void @unknown()
1165 call void @aligned_barrier()
1166 call void @aligned_barrier()
1170 define void @loop_barrier_store() "kernel" {
1171 ; CHECK-LABEL: define {{[^@]+}}@loop_barrier_store
1172 ; CHECK-SAME: () #[[ATTR4]] {
1173 ; CHECK-NEXT: entry:
1174 ; CHECK-NEXT: br label [[LOOP:%.*]]
1176 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
1177 ; CHECK-NEXT: store i32 [[I]], ptr @G1, align 4
1178 ; CHECK-NEXT: call void @aligned_barrier()
1179 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
1180 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[I_NEXT]], 128
1181 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
1183 ; CHECK-NEXT: ret void
1189 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1190 store i32 %i, ptr @G1
1191 call void @aligned_barrier()
1192 %i.next = add nuw nsw i32 %i, 1
1193 %cond = icmp ne i32 %i.next, 128
1194 br i1 %cond, label %loop, label %exit
1200 define void @loop_barrier_end_barriers_store() "kernel" {
1201 ; CHECK-LABEL: define {{[^@]+}}@loop_barrier_end_barriers_store
1202 ; CHECK-SAME: () #[[ATTR4]] {
1203 ; CHECK-NEXT: entry:
1204 ; CHECK-NEXT: br label [[LOOP:%.*]]
1206 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
1207 ; CHECK-NEXT: store i32 [[I]], ptr @G1, align 4
1208 ; CHECK-NEXT: call void @aligned_barrier()
1209 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
1210 ; CHECK-NEXT: [[COND:%.*]] = icmp ne i32 [[I_NEXT]], 128
1211 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
1213 ; CHECK-NEXT: store i32 [[I_NEXT]], ptr @G1, align 4
1214 ; CHECK-NEXT: ret void
1220 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
1221 store i32 %i, ptr @G1
1222 call void @aligned_barrier()
1223 %i.next = add nuw nsw i32 %i, 1
1224 %cond = icmp ne i32 %i.next, 128
1225 br i1 %cond, label %loop, label %exit
1228 call void @aligned_barrier()
1229 call void @aligned_barrier()
1230 store i32 %i.next, ptr @G1
1231 call void @aligned_barrier()
1232 call void @aligned_barrier()
1236 !llvm.module.flags = !{!16,!15}
1237 !nvvm.annotations = !{!0,!1,!2,!3,!4,!5,!6,!7,!8,!9,!10,!11,!12,!13,!14,!17,!18,!19,!20,!21,!22,!23,!24,!25,!26,!27,!28,!29,!30}
1239 !0 = !{ptr @pos_empty_1, !"kernel", i32 1}
1240 !1 = !{ptr @pos_empty_2, !"kernel", i32 1}
1241 !2 = !{ptr @pos_empty_3, !"kernel", i32 1}
1242 !3 = !{ptr @pos_empty_4, !"kernel", i32 1}
1243 !4 = !{ptr @pos_empty_5, !"kernel", i32 1}
1244 !5 = !{ptr @pos_empty_6, !"kernel", i32 1}
1245 !17 = !{ptr @pos_empty_7a, !"kernel", i32 1}
1246 !18 = !{ptr @pos_empty_7b, !"kernel", i32 1}
1247 !23 = !{ptr @pos_empty_8, !"kernel", i32 1}
1248 !24 = !{ptr @caller_barrier1, !"kernel", i32 1}
1249 !25 = !{ptr @caller_barrier2, !"kernel", i32 1}
1250 !26 = !{ptr @loop_barrier, !"kernel", i32 1}
1251 !27 = !{ptr @loop_barrier_end_barriers, !"kernel", i32 1}
1252 !28 = !{ptr @loop_barrier_end_barriers_unknown, !"kernel", i32 1}
1253 !29 = !{ptr @loop_barrier_store, !"kernel", i32 1}
1254 !30 = !{ptr @loop_barrier_end_barriers_store, !"kernel", i32 1}
1255 !6 = !{ptr @neg_empty_8, !"kernel", i32 1}
1256 !19 = !{ptr @neg_empty_9, !"kernel", i32 1}
1257 !20 = !{ptr @pos_empty_10, !"kernel", i32 1}
1258 !21 = !{ptr @pos_empty_11, !"kernel", i32 1}
1259 !22 = !{ptr @neg_empty_12, !"kernel", i32 1}
1260 !7 = !{ptr @pos_constant_loads, !"kernel", i32 1}
1261 !8 = !{ptr @neg_loads, !"kernel", i32 1}
1262 !9 = !{ptr @pos_priv_mem, !"kernel", i32 1}
1263 !10 = !{ptr @neg_mem, !"kernel", i32 1}
1264 !11 = !{ptr @pos_multiple, !"kernel", i32 1}
1265 !12 = !{ptr @multiple_blocks_kernel_1, !"kernel", i32 1}
1266 !13 = !{ptr @multiple_blocks_kernel_2, !"kernel", i32 1}
1267 !14 = !{ptr @multiple_blocks_functions_kernel_effects_0, !"kernel", i32 1}
1268 !15 = !{i32 7, !"openmp", i32 50}
1269 !16 = !{i32 7, !"openmp-device", i32 50}
1271 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { "llvm.assume"="ompx_aligned_barrier" }
1272 ; CHECK: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
1273 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree nounwind willreturn }
1274 ; CHECK: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
1275 ; CHECK: attributes #[[ATTR4]] = { "kernel" }
1276 ; CHECK: attributes #[[ATTR5]] = { nosync memory(none) }
1278 ; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
1279 ; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 50}
1280 ; CHECK: [[META2:![0-9]+]] = !{ptr @pos_empty_1, !"kernel", i32 1}
1281 ; CHECK: [[META3:![0-9]+]] = !{ptr @pos_empty_2, !"kernel", i32 1}
1282 ; CHECK: [[META4:![0-9]+]] = !{ptr @pos_empty_3, !"kernel", i32 1}
1283 ; CHECK: [[META5:![0-9]+]] = !{ptr @pos_empty_4, !"kernel", i32 1}
1284 ; CHECK: [[META6:![0-9]+]] = !{ptr @pos_empty_5, !"kernel", i32 1}
1285 ; CHECK: [[META7:![0-9]+]] = !{ptr @pos_empty_6, !"kernel", i32 1}
1286 ; CHECK: [[META8:![0-9]+]] = !{ptr @neg_empty_8, !"kernel", i32 1}
1287 ; CHECK: [[META9:![0-9]+]] = !{ptr @pos_constant_loads, !"kernel", i32 1}
1288 ; CHECK: [[META10:![0-9]+]] = !{ptr @neg_loads, !"kernel", i32 1}
1289 ; CHECK: [[META11:![0-9]+]] = !{ptr @pos_priv_mem, !"kernel", i32 1}
1290 ; CHECK: [[META12:![0-9]+]] = !{ptr @neg_mem, !"kernel", i32 1}
1291 ; CHECK: [[META13:![0-9]+]] = !{ptr @pos_multiple, !"kernel", i32 1}
1292 ; CHECK: [[META14:![0-9]+]] = !{ptr @multiple_blocks_kernel_1, !"kernel", i32 1}
1293 ; CHECK: [[META15:![0-9]+]] = !{ptr @multiple_blocks_kernel_2, !"kernel", i32 1}
1294 ; CHECK: [[META16:![0-9]+]] = !{ptr @multiple_blocks_functions_kernel_effects_0, !"kernel", i32 1}
1295 ; CHECK: [[META17:![0-9]+]] = !{ptr @pos_empty_7a, !"kernel", i32 1}
1296 ; CHECK: [[META18:![0-9]+]] = !{ptr @pos_empty_7b, !"kernel", i32 1}
1297 ; CHECK: [[META19:![0-9]+]] = !{ptr @neg_empty_9, !"kernel", i32 1}
1298 ; CHECK: [[META20:![0-9]+]] = !{ptr @pos_empty_10, !"kernel", i32 1}
1299 ; CHECK: [[META21:![0-9]+]] = !{ptr @pos_empty_11, !"kernel", i32 1}
1300 ; CHECK: [[META22:![0-9]+]] = !{ptr @neg_empty_12, !"kernel", i32 1}
1301 ; CHECK: [[META23:![0-9]+]] = !{ptr @pos_empty_8, !"kernel", i32 1}
1302 ; CHECK: [[META24:![0-9]+]] = !{ptr @caller_barrier1, !"kernel", i32 1}
1303 ; CHECK: [[META25:![0-9]+]] = !{ptr @caller_barrier2, !"kernel", i32 1}
1304 ; CHECK: [[META26:![0-9]+]] = !{ptr @loop_barrier, !"kernel", i32 1}
1305 ; CHECK: [[META27:![0-9]+]] = !{ptr @loop_barrier_end_barriers, !"kernel", i32 1}
1306 ; CHECK: [[META28:![0-9]+]] = !{ptr @loop_barrier_end_barriers_unknown, !"kernel", i32 1}
1307 ; CHECK: [[META29:![0-9]+]] = !{ptr @loop_barrier_store, !"kernel", i32 1}
1308 ; CHECK: [[META30:![0-9]+]] = !{ptr @loop_barrier_end_barriers_store, !"kernel", i32 1}