1 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
8 ; for (int i = 0; i < 10; ++i) {
11 ; for (int j = 0; j < 2; ++j) {
12 ; for (int k = 0; k < 2; ++k) {
23 ; [numthreads(1, 1, 1)]
28 ; CHECK: %[[#func_11:]] = OpFunction %[[#uint:]] DontInline %[[#]]
29 ; CHECK: %[[#bb41:]] = OpLabel
30 ; CHECK: OpBranch %[[#bb42:]]
31 ; CHECK: %[[#bb42:]] = OpLabel
32 ; CHECK: OpLoopMerge %[[#bb43:]] %[[#bb44:]] None
33 ; CHECK: OpBranchConditional %[[#]] %[[#bb45:]] %[[#bb43:]]
34 ; CHECK: %[[#bb45:]] = OpLabel
35 ; CHECK: OpBranch %[[#bb46:]]
36 ; CHECK: %[[#bb46:]] = OpLabel
37 ; CHECK: OpLoopMerge %[[#bb47:]] %[[#bb48:]] None
38 ; CHECK: OpBranchConditional %[[#]] %[[#bb49:]] %[[#bb47:]]
39 ; CHECK: %[[#bb49:]] = OpLabel
40 ; CHECK: OpBranch %[[#bb50:]]
41 ; CHECK: %[[#bb50:]] = OpLabel
42 ; CHECK: OpLoopMerge %[[#bb51:]] %[[#bb52:]] None
43 ; CHECK: OpBranchConditional %[[#]] %[[#bb53:]] %[[#bb51:]]
44 ; CHECK: %[[#bb53:]] = OpLabel
45 ; CHECK: OpBranch %[[#bb52:]]
46 ; CHECK: %[[#bb52:]] = OpLabel
47 ; CHECK: OpBranch %[[#bb50:]]
48 ; CHECK: %[[#bb51:]] = OpLabel
49 ; CHECK: OpBranch %[[#bb48:]]
50 ; CHECK: %[[#bb48:]] = OpLabel
51 ; CHECK: OpBranch %[[#bb46:]]
52 ; CHECK: %[[#bb47:]] = OpLabel
53 ; CHECK: OpBranch %[[#bb44:]]
54 ; CHECK: %[[#bb44:]] = OpLabel
55 ; CHECK: OpBranch %[[#bb42:]]
56 ; CHECK: %[[#bb43:]] = OpLabel
57 ; CHECK: OpReturnValue %[[#]]
58 ; CHECK: OpFunctionEnd
59 ; CHECK: %[[#func_37:]] = OpFunction %[[#void:]] DontInline %[[#]]
60 ; CHECK: %[[#bb54:]] = OpLabel
62 ; CHECK: OpFunctionEnd
63 ; CHECK: %[[#func_39:]] = OpFunction %[[#void:]] None %[[#]]
64 ; CHECK: %[[#bb55:]] = OpLabel
66 ; CHECK: OpFunctionEnd
70 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
71 target triple = "spirv-unknown-vulkan1.3-compute"
73 ; Function Attrs: convergent noinline norecurse nounwind optnone
74 define spir_func noundef i32 @_Z7processv() #0 {
76 %0 = call token @llvm.experimental.convergence.entry()
77 %val = alloca i32, align 4
78 %i = alloca i32, align 4
79 %j = alloca i32, align 4
80 %k = alloca i32, align 4
81 store i32 0, ptr %val, align 4
82 store i32 0, ptr %i, align 4
85 for.cond: ; preds = %for.inc11, %entry
86 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
87 %2 = load i32, ptr %i, align 4
88 %cmp = icmp slt i32 %2, 10
89 br i1 %cmp, label %for.body, label %for.end13
91 for.body: ; preds = %for.cond
92 %3 = load i32, ptr %val, align 4
93 %4 = load i32, ptr %i, align 4
94 %add = add nsw i32 %3, %4
95 store i32 %add, ptr %val, align 4
96 store i32 0, ptr %j, align 4
99 for.cond1: ; preds = %for.inc8, %for.body
100 %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
101 %6 = load i32, ptr %j, align 4
102 %cmp2 = icmp slt i32 %6, 2
103 br i1 %cmp2, label %for.body3, label %for.end10
105 for.body3: ; preds = %for.cond1
106 store i32 0, ptr %k, align 4
109 for.cond4: ; preds = %for.inc, %for.body3
110 %7 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %5) ]
111 %8 = load i32, ptr %k, align 4
112 %cmp5 = icmp slt i32 %8, 2
113 br i1 %cmp5, label %for.body6, label %for.end
115 for.body6: ; preds = %for.cond4
116 %9 = load i32, ptr %val, align 4
117 %10 = load i32, ptr %k, align 4
118 %add7 = add nsw i32 %9, %10
119 store i32 %add7, ptr %val, align 4
122 for.inc: ; preds = %for.body6
123 %11 = load i32, ptr %k, align 4
124 %inc = add nsw i32 %11, 1
125 store i32 %inc, ptr %k, align 4
128 for.end: ; preds = %for.cond4
129 %12 = load i32, ptr %val, align 4
130 %mul = mul nsw i32 %12, 2
131 store i32 %mul, ptr %val, align 4
134 for.inc8: ; preds = %for.end
135 %13 = load i32, ptr %j, align 4
136 %inc9 = add nsw i32 %13, 1
137 store i32 %inc9, ptr %j, align 4
140 for.end10: ; preds = %for.cond1
143 for.inc11: ; preds = %for.end10
144 %14 = load i32, ptr %i, align 4
145 %inc12 = add nsw i32 %14, 1
146 store i32 %inc12, ptr %i, align 4
149 for.end13: ; preds = %for.cond
150 %15 = load i32, ptr %val, align 4
154 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
155 declare token @llvm.experimental.convergence.entry() #1
157 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
158 declare token @llvm.experimental.convergence.loop() #1
160 ; Function Attrs: convergent noinline norecurse nounwind optnone
161 define internal spir_func void @main() #0 {
163 %0 = call token @llvm.experimental.convergence.entry()
164 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
168 ; Function Attrs: convergent norecurse
169 define void @main.1() #2 {
175 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
176 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
177 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
178 attributes #3 = { convergent }
180 !llvm.module.flags = !{!0, !1, !2}
183 !0 = !{i32 1, !"wchar_size", i32 4}
184 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
185 !2 = !{i32 7, !"frame-pointer", i32 2}