1; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %} 2 3; int foo() { return true; } 4; 5; int process() { 6; int val = 0; 7; int i = 0; 8; 9; do { 10; ++i; 11; if (i > 5) { 12; break; 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. 16; } 17; 18; val = i; 19; { 20; { 21; break; 22; } 23; } 24; val = val * 2; // No SPIR-V should be emitted for this statement. 25; 26; } while (i < 10); 27; 28; //////////////////////////////////////////////////////////////////////////////// 29; // Nested do-while loops with break statements // 30; // Each break statement should branch to the corresponding loop's break block // 31; //////////////////////////////////////////////////////////////////////////////// 32; 33; do { 34; ++i; 35; 36; do { 37; ++val; 38; break; 39; } while (i < 10); 40; 41; --i; 42; 43; { 44; break; 45; } 46; 47; } while(val < 10); 48; 49; return val; 50; } 51; 52; [numthreads(1, 1, 1)] 53; void main() { 54; process(); 55; } 56 57target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1" 58target triple = "spirv-unknown-vulkan1.3-compute" 59 60; Function Attrs: convergent noinline nounwind optnone 61define spir_func noundef i32 @_Z3foov() #0 { 62entry: 63 %0 = call token @llvm.experimental.convergence.entry() 64 ret i32 1 65} 66 67; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none) 68declare token @llvm.experimental.convergence.entry() #1 69 70; Function Attrs: convergent noinline nounwind optnone 71define spir_func noundef i32 @_Z7processv() #0 { 72entry: 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 78 br label %do.body 79 80do.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 88 89if.then: ; preds = %do.body 90 br label %do.end 91 92if.end: ; preds = %do.body 93 %4 = load i32, ptr %i, align 4 94 store i32 %4, ptr %val, align 4 95 br label %do.end 96 97do.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 101 102do.end: ; preds = %do.cond, %if.end, %if.then 103 br label %do.body2 104 105do.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 110 br label %do.body4 111 112do.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 117 br label %do.end8 118 119do.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 123 124do.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 128 br label %do.end11 129 130do.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 134 135do.end11: ; preds = %do.cond9, %do.end8 136 %13 = load i32, ptr %val, align 4 137 ret i32 %13 138} 139 140; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none) 141declare token @llvm.experimental.convergence.loop() #1 142 143; Function Attrs: convergent noinline norecurse nounwind optnone 144define internal spir_func void @main() #2 { 145entry: 146 %0 = call token @llvm.experimental.convergence.entry() 147 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ] 148 ret void 149} 150 151; Function Attrs: convergent norecurse 152define void @main.1() #3 { 153entry: 154 call void @main() 155 ret void 156} 157 158attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 159attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) } 160attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 161attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 162attributes #4 = { convergent } 163 164!llvm.module.flags = !{!0, !1, !2} 165 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} 169