1 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
2 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s --match-full-lines
4 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
5 target triple = "spirv-unknown-vulkan1.3-compute"
7 define internal spir_func void @main() #1 {
8 ; CHECK: %[[#entry:]] = OpLabel
9 ; CHECK: OpBranch %[[#do_body:]]
11 %0 = call token @llvm.experimental.convergence.entry()
12 %val = alloca i32, align 4
13 %i = alloca i32, align 4
14 store i32 0, ptr %val, align 4
15 store i32 0, ptr %i, align 4
18 ; CHECK: %[[#do_body]] = OpLabel
19 ; CHECK: OpSelectionMerge %[[#do_end:]] None
20 ; CHECK: OpBranchConditional %[[#cond:]] %[[#do_end]] %[[#if_end:]]
22 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
23 %2 = load i32, ptr %i, align 4
24 %inc = add nsw i32 %2, 1
25 store i32 %inc, ptr %i, align 4
26 %3 = load i32, ptr %i, align 4
27 %cmp = icmp sgt i32 %3, 5
28 br i1 %cmp, label %if.then, label %if.end
30 ; CHECK: %[[#if_end]] = OpLabel
31 ; CHECK: OpBranch %[[#do_end]]
33 %4 = load i32, ptr %i, align 4
34 store i32 %4, ptr %val, align 4
41 ; CHECK: %[[#do_end]] = OpLabel
42 ; CHECK: OpBranch %[[#do_body2:]]
46 ; CHECK: %[[#do_body2]] = OpLabel
47 ; CHECK: OpBranch %[[#do_body4:]]
49 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
50 %7 = load i32, ptr %i, align 4
51 %inc3 = add nsw i32 %7, 1
52 store i32 %inc3, ptr %i, align 4
55 ; CHECK: %[[#do_body4]] = OpLabel
56 ; CHECK: OpBranch %[[#do_end8:]]
58 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]
59 %9 = load i32, ptr %val, align 4
60 %inc5 = add nsw i32 %9, 1
61 store i32 %inc5, ptr %val, align 4
64 ; CHECK: %[[#do_end8]] = OpLabel
65 ; CHECK: OpBranch %[[#do_end11:]]
67 %11 = load i32, ptr %i, align 4
68 %dec = add nsw i32 %11, -1
69 store i32 %dec, ptr %i, align 4
72 ; CHECK: %[[#do_end11]] = OpLabel
80 declare token @llvm.experimental.convergence.entry() #0
81 declare token @llvm.experimental.convergence.loop() #0
83 attributes #0 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
84 attributes #1 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
86 !llvm.module.flags = !{!0, !1}
88 !0 = !{i32 1, !"wchar_size", i32 4}
89 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}