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 %}
5 ; int foo() { return true; }
7 ; [numthreads(1, 1, 1)]
20 ; val++; // No SPIR-V should be emitted for this statement.
21 ; continue; // No SPIR-V should be emitted for this statement.
22 ; while(true); // No SPIR-V should be emitted for this statement.
23 ; --i; // No SPIR-V should be emitted for this statement.
28 ; //////////////////////////////////////////////////////////////////////////////////////
29 ; // Nested while loops with continue statements //
30 ; // Each continue statement should branch to the corresponding loop's continue block //
31 ; //////////////////////////////////////////////////////////////////////////////////////
42 ; continue; // No SPIR-V should be emitted for this statement.
47 ; CHECK: %[[#func_15:]] = OpFunction %[[#uint:]] DontInline %[[#]]
48 ; CHECK: %[[#bb35:]] = OpLabel
49 ; CHECK: OpReturnValue %[[#]]
50 ; CHECK: OpFunctionEnd
51 ; CHECK: %[[#func_16:]] = OpFunction %[[#void:]] DontInline %[[#]]
52 ; CHECK: %[[#bb36:]] = OpLabel
53 ; CHECK: OpBranch %[[#bb37:]]
54 ; CHECK: %[[#bb37:]] = OpLabel
55 ; CHECK: OpLoopMerge %[[#bb38:]] %[[#bb39:]] None
56 ; CHECK: OpBranchConditional %[[#]] %[[#bb40:]] %[[#bb38:]]
57 ; CHECK: %[[#bb40:]] = OpLabel
58 ; CHECK: OpSelectionMerge %[[#bb41:]] None
59 ; CHECK: OpBranchConditional %[[#]] %[[#bb41:]] %[[#bb42:]]
60 ; CHECK: %[[#bb42:]] = OpLabel
61 ; CHECK: OpSelectionMerge %[[#bb43:]] None
62 ; CHECK: OpBranchConditional %[[#]] %[[#bb43:]] %[[#bb44:]]
63 ; CHECK: %[[#bb44:]] = OpLabel
64 ; CHECK: OpBranch %[[#bb43:]]
65 ; CHECK: %[[#bb43:]] = OpLabel
66 ; CHECK: OpBranch %[[#bb41:]]
67 ; CHECK: %[[#bb41:]] = OpLabel
68 ; CHECK: OpBranch %[[#bb39:]]
69 ; CHECK: %[[#bb39:]] = OpLabel
70 ; CHECK: OpBranch %[[#bb37:]]
71 ; CHECK: %[[#bb38:]] = OpLabel
72 ; CHECK: OpBranch %[[#bb45:]]
73 ; CHECK: %[[#bb45:]] = OpLabel
74 ; CHECK: OpLoopMerge %[[#bb46:]] %[[#bb47:]] None
75 ; CHECK: OpBranchConditional %[[#]] %[[#bb46:]] %[[#bb48:]]
76 ; CHECK: %[[#bb48:]] = OpLabel
77 ; CHECK: OpBranch %[[#bb49:]]
78 ; CHECK: %[[#bb49:]] = OpLabel
79 ; CHECK: OpLoopMerge %[[#bb50:]] %[[#bb51:]] None
80 ; CHECK: OpBranchConditional %[[#]] %[[#bb51:]] %[[#bb50:]]
81 ; CHECK: %[[#bb51:]] = OpLabel
82 ; CHECK: OpBranch %[[#bb49:]]
83 ; CHECK: %[[#bb50:]] = OpLabel
84 ; CHECK: OpBranch %[[#bb47:]]
85 ; CHECK: %[[#bb47:]] = OpLabel
86 ; CHECK: OpBranch %[[#bb45:]]
87 ; CHECK: %[[#bb46:]] = OpLabel
88 ; CHECK: OpFunctionEnd
89 ; CHECK: %[[#func_33:]] = OpFunction %[[#void:]] None %[[#]]
90 ; CHECK: %[[#bb52:]] = OpLabel
92 ; CHECK: OpFunctionEnd
96 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
97 target triple = "spirv-unknown-vulkan1.3-compute"
99 ; Function Attrs: convergent noinline norecurse nounwind optnone
100 define spir_func noundef i32 @_Z3foov() #0 {
102 %0 = call token @llvm.experimental.convergence.entry()
106 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
107 declare token @llvm.experimental.convergence.entry() #1
109 ; Function Attrs: convergent noinline norecurse nounwind optnone
110 define internal spir_func void @main() #0 {
112 %0 = call token @llvm.experimental.convergence.entry()
113 %val = alloca i32, align 4
114 %i = alloca i32, align 4
115 store i32 0, ptr %val, align 4
116 store i32 0, ptr %i, align 4
119 while.cond: ; preds = %if.end4, %if.then3, %if.then, %entry
120 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
121 %2 = load i32, ptr %i, align 4
122 %cmp = icmp slt i32 %2, 10
123 br i1 %cmp, label %while.body, label %while.end
125 while.body: ; preds = %while.cond
126 %3 = load i32, ptr %i, align 4
127 store i32 %3, ptr %val, align 4
128 %4 = load i32, ptr %val, align 4
129 %cmp1 = icmp sgt i32 %4, 5
130 br i1 %cmp1, label %if.then, label %if.end
132 if.then: ; preds = %while.body
135 if.end: ; preds = %while.body
136 %5 = load i32, ptr %val, align 4
137 %cmp2 = icmp sgt i32 %5, 6
138 br i1 %cmp2, label %if.then3, label %if.end4
140 if.then3: ; preds = %if.end
143 if.end4: ; preds = %if.end
146 while.end: ; preds = %while.cond
147 br label %while.cond5
149 while.cond5: ; preds = %while.end10, %while.end
150 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
151 br label %while.body6
153 while.body6: ; preds = %while.cond5
154 %7 = load i32, ptr %i, align 4
155 %inc = add nsw i32 %7, 1
156 store i32 %inc, ptr %i, align 4
157 br label %while.cond7
159 while.cond7: ; preds = %while.body9, %while.body6
160 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]
161 %9 = load i32, ptr %i, align 4
162 %cmp8 = icmp slt i32 %9, 20
163 br i1 %cmp8, label %while.body9, label %while.end10
165 while.body9: ; preds = %while.cond7
166 %10 = load i32, ptr %i, align 4
167 store i32 %10, ptr %val, align 4
168 br label %while.cond7
170 while.end10: ; preds = %while.cond7
171 %11 = load i32, ptr %i, align 4
172 %dec = add nsw i32 %11, -1
173 store i32 %dec, ptr %i, align 4
174 br label %while.cond5
177 ; Function Attrs: convergent norecurse
178 define void @main.1() #2 {
184 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
185 declare token @llvm.experimental.convergence.loop() #1
187 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
188 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
189 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
191 !llvm.module.flags = !{!0, !1, !2}
194 !0 = !{i32 1, !"wchar_size", i32 4}
195 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
196 !2 = !{i32 7, !"frame-pointer", i32 2}