199 lines · plain
1; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}3 4;5; int foo() { return true; }6;7; [numthreads(1, 1, 1)]8; void main() {9; int val = 0;10; int i = 0;11;12; while (i < 10) {13; val = i;14; if (val > 5) {15; continue;16; }17;18; if (val > 6) {19; {{continue;}}20; val++; // No SPIR-V should be emitted for this statement.21; continue; // No SPIR-V should be emitted for this statement.22; while(true); // No SPIR-V should be emitted for this statement.23; --i; // No SPIR-V should be emitted for this statement.24; }25;26; }27;28; //////////////////////////////////////////////////////////////////////////////////////29; // Nested while loops with continue statements //30; // Each continue statement should branch to the corresponding loop's continue block //31; //////////////////////////////////////////////////////////////////////////////////////32;33; while (true) {34; i++;35;36; while(i<20) {37; val = i;38; continue;39; }40; --i;41; continue;42; continue; // No SPIR-V should be emitted for this statement.43;44; }45; }46 47; CHECK: %[[#func_15:]] = OpFunction %[[#uint:]] DontInline %[[#]]48; CHECK: %[[#bb36:]] = OpLabel49; CHECK: OpReturnValue %[[#]]50; CHECK: OpFunctionEnd51 52; CHECK: %[[#func_16:]] = OpFunction %[[#void:]] DontInline %[[#]]53; CHECK: %[[#bb37:]] = OpLabel54; CHECK: OpBranch %[[#bb38:]]55; CHECK: %[[#bb38]] = OpLabel56; CHECK: OpLoopMerge %[[#bb39:]] %[[#bb40:]] None57; CHECK: OpBranchConditional %[[#]] %[[#bb41:]] %[[#bb39]]58; CHECK: %[[#bb39]] = OpLabel59; CHECK: OpBranch %[[#bb42:]]60; CHECK: %[[#bb42]] = OpLabel61; CHECK: OpLoopMerge %[[#bb43:]] %[[#bb44:]] None62; CHECK: OpBranchConditional %[[#]] %[[#bb43]] %[[#bb45:]]63; CHECK: %[[#bb45]] = OpLabel64; CHECK: OpBranch %[[#bb46:]]65; CHECK: %[[#bb46]] = OpLabel66; CHECK: OpLoopMerge %[[#bb47:]] %[[#bb48:]] None67; CHECK: OpBranchConditional %[[#]] %[[#bb48]] %[[#bb47]]68; CHECK: %[[#bb47]] = OpLabel69; CHECK: OpBranch %[[#bb44]]70; CHECK: %[[#bb44]] = OpLabel71; CHECK: OpBranch %[[#bb42]]72; CHECK: %[[#bb48]] = OpLabel73; CHECK: OpBranch %[[#bb46]]74; CHECK: %[[#bb43]] = OpLabel75; CHECK: %[[#bb41]] = OpLabel76; CHECK: OpSelectionMerge %[[#bb49:]] None77; CHECK: OpBranchConditional %[[#]] %[[#bb49]] %[[#bb50:]]78; CHECK: %[[#bb50]] = OpLabel79; CHECK: OpSelectionMerge %[[#bb51:]] None80; CHECK: OpBranchConditional %[[#]] %[[#bb51]] %[[#bb52:]]81; CHECK: %[[#bb52]] = OpLabel82; CHECK: OpBranch %[[#bb51]]83; CHECK: %[[#bb51]] = OpLabel84; CHECK: OpBranch %[[#bb49]]85; CHECK: %[[#bb49]] = OpLabel86; CHECK: OpBranch %[[#bb40]]87; CHECK: %[[#bb40]] = OpLabel88; CHECK: OpBranch %[[#bb38]]89; CHECK: OpFunctionEnd90 91; CHECK: %[[#func_34:]] = OpFunction %[[#void]] None %[[#]]92; CHECK: %[[#bb53:]] = OpLabel93; CHECK: OpReturn94; CHECK: OpFunctionEnd95 96target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"97target triple = "spirv-unknown-vulkan1.3-compute"98 99; Function Attrs: convergent noinline norecurse nounwind optnone100define spir_func noundef i32 @_Z3foov() #0 {101entry:102 %0 = call token @llvm.experimental.convergence.entry()103 ret i32 1104}105 106; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)107declare token @llvm.experimental.convergence.entry() #1108 109; Function Attrs: convergent noinline norecurse nounwind optnone110define internal spir_func void @main() #0 {111entry:112 %0 = call token @llvm.experimental.convergence.entry()113 %val = alloca i32, align 4114 %i = alloca i32, align 4115 store i32 0, ptr %val, align 4116 store i32 0, ptr %i, align 4117 br label %while.cond118 119while.cond: ; preds = %if.end4, %if.then3, %if.then, %entry120 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]121 %2 = load i32, ptr %i, align 4122 %cmp = icmp slt i32 %2, 10123 br i1 %cmp, label %while.body, label %while.end124 125while.body: ; preds = %while.cond126 %3 = load i32, ptr %i, align 4127 store i32 %3, ptr %val, align 4128 %4 = load i32, ptr %val, align 4129 %cmp1 = icmp sgt i32 %4, 5130 br i1 %cmp1, label %if.then, label %if.end131 132if.then: ; preds = %while.body133 br label %while.cond134 135if.end: ; preds = %while.body136 %5 = load i32, ptr %val, align 4137 %cmp2 = icmp sgt i32 %5, 6138 br i1 %cmp2, label %if.then3, label %if.end4139 140if.then3: ; preds = %if.end141 br label %while.cond142 143if.end4: ; preds = %if.end144 br label %while.cond145 146while.end: ; preds = %while.cond147 br label %while.cond5148 149while.cond5: ; preds = %while.end10, %while.end150 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]151 br label %while.body6152 153while.body6: ; preds = %while.cond5154 %7 = load i32, ptr %i, align 4155 %inc = add nsw i32 %7, 1156 store i32 %inc, ptr %i, align 4157 br label %while.cond7158 159while.cond7: ; preds = %while.body9, %while.body6160 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]161 %9 = load i32, ptr %i, align 4162 %cmp8 = icmp slt i32 %9, 20163 br i1 %cmp8, label %while.body9, label %while.end10164 165while.body9: ; preds = %while.cond7166 %10 = load i32, ptr %i, align 4167 store i32 %10, ptr %val, align 4168 br label %while.cond7169 170while.end10: ; preds = %while.cond7171 %11 = load i32, ptr %i, align 4172 %dec = add nsw i32 %11, -1173 store i32 %dec, ptr %i, align 4174 br label %while.cond5175}176 177; Function Attrs: convergent norecurse178define void @main.1() #2 {179entry:180 call void @main()181 ret void182}183 184; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)185declare token @llvm.experimental.convergence.loop() #1186 187attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }188attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }189attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }190 191!llvm.module.flags = !{!0, !1, !2}192 193 194!0 = !{i32 1, !"wchar_size", i32 4}195!1 = !{i32 4, !"dx.disable_optimizations", i32 1}196!2 = !{i32 7, !"frame-pointer", i32 2}197 198 199