167 lines · plain
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 optnone59define spir_func noundef i32 @_Z3foov() #0 {60entry:61 %0 = call token @llvm.experimental.convergence.entry()62 ret i32 163}64 65; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)66declare token @llvm.experimental.convergence.entry() #167 68; Function Attrs: convergent noinline nounwind optnone69define spir_func noundef i32 @_Z7processv() #0 {70entry:71 %0 = call token @llvm.experimental.convergence.entry()72 %val = alloca i32, align 473 %i = alloca i32, align 474 store i32 0, ptr %val, align 475 store i32 0, ptr %i, align 476 br label %do.body77 78do.body: ; preds = %do.cond, %entry79 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]80 %2 = load i32, ptr %i, align 481 %inc = add nsw i32 %2, 182 store i32 %inc, ptr %i, align 483 %3 = load i32, ptr %i, align 484 %cmp = icmp sgt i32 %3, 585 br i1 %cmp, label %if.then, label %if.end86 87if.then: ; preds = %do.body88 br label %do.cond89 90if.end: ; preds = %do.body91 %4 = load i32, ptr %i, align 492 store i32 %4, ptr %val, align 493 br label %do.cond94 95do.cond: ; preds = %if.end, %if.then96 %5 = load i32, ptr %i, align 497 %cmp1 = icmp slt i32 %5, 1098 br i1 %cmp1, label %do.body, label %do.end99 100do.end: ; preds = %do.cond101 br label %do.body2102 103do.body2: ; preds = %do.cond9, %do.end104 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]105 %7 = load i32, ptr %i, align 4106 %inc3 = add nsw i32 %7, 1107 store i32 %inc3, ptr %i, align 4108 br label %do.body4109 110do.body4: ; preds = %do.cond6, %do.body2111 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]112 %9 = load i32, ptr %val, align 4113 %inc5 = add nsw i32 %9, 1114 store i32 %inc5, ptr %val, align 4115 br label %do.cond6116 117do.cond6: ; preds = %do.body4118 %10 = load i32, ptr %i, align 4119 %cmp7 = icmp slt i32 %10, 10120 br i1 %cmp7, label %do.body4, label %do.end8121 122do.end8: ; preds = %do.cond6123 %11 = load i32, ptr %i, align 4124 %dec = add nsw i32 %11, -1125 store i32 %dec, ptr %i, align 4126 br label %do.cond9127 128do.cond9: ; preds = %do.end8129 %12 = load i32, ptr %val, align 4130 %cmp10 = icmp slt i32 %12, 10131 br i1 %cmp10, label %do.body2, label %do.end11132 133do.end11: ; preds = %do.cond9134 %13 = load i32, ptr %val, align 4135 ret i32 %13136}137 138; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)139declare token @llvm.experimental.convergence.loop() #1140 141; Function Attrs: convergent noinline norecurse nounwind optnone142define 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 void147}148 149; Function Attrs: convergent norecurse150define void @main.1() #3 {151entry:152 call void @main()153 ret void154}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