1 ; RUN: %if spirv-tools %{ llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | spirv-as --preserve-numeric-ids - -o - | spirv-val %}
8 ; for (int i = 0; i < 10; ++i) {
16 ; break; // No SPIR-V should be emitted for this statement.
17 ; val++; // No SPIR-V should be emitted for this statement.
18 ; while(true); // No SPIR-V should be emitted for this statement.
21 ; ////////////////////////////////////////////////////////////////////////////////
22 ; // Nested for loops with break statements //
23 ; // Each break statement should branch to the corresponding loop's break block //
24 ; ////////////////////////////////////////////////////////////////////////////////
25 ; for (int j = 0; j < 10; ++j) {
27 ; for ( ; val < 20; ++val) {
34 ; k++; // No SPIR-V should be emitted for this statement.
37 ; // FIXME: val--; generates add nsw i32 ..., -1
38 ; // This is compiled into a OpIAdd %val, MAX_INT.
41 ; break; // No SPIR-V should be emitted for this statement.
42 ; val = val*10; // No SPIR-V should be emitted for this statement.
48 ; [numthreads(1, 1, 1)]
53 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
54 target triple = "spirv-unknown-vulkan1.3-compute"
56 ; Function Attrs: convergent noinline nounwind optnone
57 define spir_func noundef i32 @_Z7processv() #0 {
59 %0 = call token @llvm.experimental.convergence.entry()
60 %val = alloca i32, align 4
61 %i = alloca i32, align 4
62 %j = alloca i32, align 4
63 %k = alloca i32, align 4
64 store i32 0, ptr %val, align 4
65 store i32 0, ptr %i, align 4
68 for.cond: ; preds = %for.inc, %entry
69 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
70 %2 = load i32, ptr %i, align 4
71 %cmp = icmp slt i32 %2, 10
72 br i1 %cmp, label %for.body, label %for.end
74 for.body: ; preds = %for.cond
75 %3 = load i32, ptr %i, align 4
76 %cmp1 = icmp slt i32 %3, 5
77 br i1 %cmp1, label %if.then, label %if.end
79 if.then: ; preds = %for.body
82 if.end: ; preds = %for.body
83 %4 = load i32, ptr %i, align 4
84 store i32 %4, ptr %val, align 4
87 for.inc: ; No predecessors!
88 %5 = load i32, ptr %i, align 4
89 %inc = add nsw i32 %5, 1
90 store i32 %inc, ptr %i, align 4
93 for.end: ; preds = %if.end, %if.then, %for.cond
94 store i32 0, ptr %j, align 4
97 for.cond2: ; preds = %for.inc12, %for.end
98 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
99 %7 = load i32, ptr %j, align 4
100 %cmp3 = icmp slt i32 %7, 10
101 br i1 %cmp3, label %for.body4, label %for.end14
103 for.body4: ; preds = %for.cond2
104 %8 = load i32, ptr %j, align 4
105 %add = add nsw i32 %8, 5
106 store i32 %add, ptr %val, align 4
109 for.cond5: ; preds = %for.inc9, %for.body4
110 %9 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]
111 %10 = load i32, ptr %val, align 4
112 %cmp6 = icmp slt i32 %10, 20
113 br i1 %cmp6, label %for.body7, label %for.end11
115 for.body7: ; preds = %for.cond5
116 %11 = load i32, ptr %val, align 4
117 %12 = load i32, ptr %j, align 4
118 %add8 = add nsw i32 %11, %12
119 store i32 %add8, ptr %k, align 4
122 for.inc9: ; No predecessors!
123 %13 = load i32, ptr %val, align 4
124 %inc10 = add nsw i32 %13, 1
125 store i32 %inc10, ptr %val, align 4
128 for.end11: ; preds = %for.body7, %for.cond5
129 %14 = load i32, ptr %val, align 4
130 %sub = sub nsw i32 %14, 1
131 store i32 %sub, ptr %val, align 4
134 for.inc12: ; No predecessors!
135 %15 = load i32, ptr %j, align 4
136 %inc13 = add nsw i32 %15, 1
137 store i32 %inc13, ptr %j, align 4
140 for.end14: ; preds = %for.end11, %for.cond2
141 %16 = load i32, ptr %val, align 4
145 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
146 declare token @llvm.experimental.convergence.entry() #1
148 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
149 declare token @llvm.experimental.convergence.loop() #1
151 ; Function Attrs: convergent noinline norecurse nounwind optnone
152 define internal spir_func void @main() #2 {
154 %0 = call token @llvm.experimental.convergence.entry()
155 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ]
159 ; Function Attrs: convergent norecurse
160 define void @main.1() #3 {
166 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
167 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
168 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
169 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
170 attributes #4 = { convergent }
172 !llvm.module.flags = !{!0, !1, !2}
174 !0 = !{i32 1, !"wchar_size", i32 4}
175 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
176 !2 = !{i32 7, !"frame-pointer", i32 2}