1 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
3 ; int foo() { return true; }
13 ; break; // No SPIR-V should be emitted for this statement.
14 ; val = i; // No SPIR-V should be emitted for this statement.
15 ; while(true); // No SPIR-V should be emitted for this statement.
24 ; val = val * 2; // No SPIR-V should be emitted for this statement.
28 ; ////////////////////////////////////////////////////////////////////////////////
29 ; // Nested do-while loops with break statements //
30 ; // Each break statement should branch to the corresponding loop's break block //
31 ; ////////////////////////////////////////////////////////////////////////////////
52 ; [numthreads(1, 1, 1)]
57 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
58 target triple = "spirv-unknown-vulkan1.3-compute"
60 ; Function Attrs: convergent noinline nounwind optnone
61 define spir_func noundef i32 @_Z3foov() #0 {
63 %0 = call token @llvm.experimental.convergence.entry()
67 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
68 declare token @llvm.experimental.convergence.entry() #1
70 ; Function Attrs: convergent noinline nounwind optnone
71 define spir_func noundef i32 @_Z7processv() #0 {
73 %0 = call token @llvm.experimental.convergence.entry()
74 %val = alloca i32, align 4
75 %i = alloca i32, align 4
76 store i32 0, ptr %val, align 4
77 store i32 0, ptr %i, align 4
80 do.body: ; preds = %do.cond, %entry
81 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
82 %2 = load i32, ptr %i, align 4
83 %inc = add nsw i32 %2, 1
84 store i32 %inc, ptr %i, align 4
85 %3 = load i32, ptr %i, align 4
86 %cmp = icmp sgt i32 %3, 5
87 br i1 %cmp, label %if.then, label %if.end
89 if.then: ; preds = %do.body
92 if.end: ; preds = %do.body
93 %4 = load i32, ptr %i, align 4
94 store i32 %4, ptr %val, align 4
97 do.cond: ; No predecessors!
98 %5 = load i32, ptr %i, align 4
99 %cmp1 = icmp slt i32 %5, 10
100 br i1 %cmp1, label %do.body, label %do.end
102 do.end: ; preds = %do.cond, %if.end, %if.then
105 do.body2: ; preds = %do.cond9, %do.end
106 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
107 %7 = load i32, ptr %i, align 4
108 %inc3 = add nsw i32 %7, 1
109 store i32 %inc3, ptr %i, align 4
112 do.body4: ; preds = %do.cond6, %do.body2
113 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]
114 %9 = load i32, ptr %val, align 4
115 %inc5 = add nsw i32 %9, 1
116 store i32 %inc5, ptr %val, align 4
119 do.cond6: ; No predecessors!
120 %10 = load i32, ptr %i, align 4
121 %cmp7 = icmp slt i32 %10, 10
122 br i1 %cmp7, label %do.body4, label %do.end8
124 do.end8: ; preds = %do.cond6, %do.body4
125 %11 = load i32, ptr %i, align 4
126 %dec = add nsw i32 %11, -1
127 store i32 %dec, ptr %i, align 4
130 do.cond9: ; No predecessors!
131 %12 = load i32, ptr %val, align 4
132 %cmp10 = icmp slt i32 %12, 10
133 br i1 %cmp10, label %do.body2, label %do.end11
135 do.end11: ; preds = %do.cond9, %do.end8
136 %13 = load i32, ptr %val, align 4
140 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
141 declare token @llvm.experimental.convergence.loop() #1
143 ; Function Attrs: convergent noinline norecurse nounwind optnone
144 define internal spir_func void @main() #2 {
146 %0 = call token @llvm.experimental.convergence.entry()
147 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ]
151 ; Function Attrs: convergent norecurse
152 define void @main.1() #3 {
158 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
159 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
160 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
161 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
162 attributes #4 = { convergent }
164 !llvm.module.flags = !{!0, !1, !2}
166 !0 = !{i32 1, !"wchar_size", i32 4}
167 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
168 !2 = !{i32 7, !"frame-pointer", i32 2}