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