189 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; break;16; }17;18; if (val > 6) {19; break;20; break; // No SPIR-V should be emitted for this statement.21; val++; // 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; // Nested while loops with break statements //29; // Each break statement should branch to the corresponding loop's break block //30; ////////////////////////////////////////////////////////////////////////////////31;32; while (true) {33; i++;34; while(i<20) {35; val = i;36; {{break;}}37; }38; --i;39; break;40; }41; }42 43; CHECK: %[[#func_16:]] = OpFunction %[[#uint:]] DontInline %[[#]]44; CHECK: %[[#bb44:]] = OpLabel45; CHECK: OpReturnValue %[[#]]46; CHECK: OpFunctionEnd47; CHECK: %[[#func_19:]] = OpFunction %[[#void:]] DontInline %[[#]]48; CHECK: %[[#bb45:]] = OpLabel49; CHECK: OpBranch %[[#bb46:]]50; CHECK: %[[#bb46:]] = OpLabel51; CHECK: OpLoopMerge %[[#bb47:]] %[[#bb48:]] None52; CHECK: OpBranchConditional %[[#]] %[[#bb49:]] %[[#bb47:]]53; CHECK: %[[#bb49:]] = OpLabel54; CHECK: OpBranchConditional %[[#]] %[[#bb47:]] %[[#bb50:]]55; CHECK: %[[#bb50:]] = OpLabel56; CHECK: OpBranchConditional %[[#]] %[[#bb47:]] %[[#bb48:]]57; CHECK: %[[#bb48:]] = OpLabel58; CHECK: OpBranch %[[#bb46:]]59; CHECK: %[[#bb47:]] = OpLabel60; CHECK: OpSelectionMerge %[[#bb51:]] None61; CHECK: OpSwitch %[[#]] %[[#bb51:]] 1 %[[#bb51:]] 2 %[[#bb51:]]62; CHECK: %[[#bb51:]] = OpLabel63; CHECK: OpBranch %[[#bb52:]]64; CHECK: %[[#bb52:]] = OpLabel65; CHECK: OpBranch %[[#bb53:]]66; CHECK: %[[#bb53:]] = OpLabel67; CHECK: OpBranch %[[#bb54:]]68; CHECK: %[[#bb54:]] = OpLabel69; CHECK: OpSelectionMerge %[[#bb55:]] None70; CHECK: OpBranchConditional %[[#]] %[[#bb56:]] %[[#bb55:]]71; CHECK: %[[#bb56:]] = OpLabel72; CHECK: OpBranch %[[#bb55:]]73; CHECK: %[[#bb55:]] = OpLabel74; CHECK: OpBranch %[[#bb57:]]75; CHECK: %[[#bb57:]] = OpLabel76; CHECK: OpReturn77; CHECK: OpFunctionEnd78; CHECK: %[[#func_40:]] = OpFunction %[[#void:]] None %[[#]]79; CHECK: %[[#bb58:]] = OpLabel80; CHECK: OpReturn81; CHECK: OpFunctionEnd82 83target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"84target triple = "spirv-unknown-vulkan1.3-compute"85 86; Function Attrs: convergent noinline norecurse nounwind optnone87define spir_func noundef i32 @_Z3foov() #0 {88entry:89 %0 = call token @llvm.experimental.convergence.entry()90 ret i32 191}92 93; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)94declare token @llvm.experimental.convergence.entry() #195 96; Function Attrs: convergent noinline norecurse nounwind optnone97define internal spir_func void @main() #0 {98entry:99 %0 = call token @llvm.experimental.convergence.entry()100 %val = alloca i32, align 4101 %i = alloca i32, align 4102 store i32 0, ptr %val, align 4103 store i32 0, ptr %i, align 4104 br label %while.cond105 106while.cond: ; preds = %if.end4, %entry107 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]108 %2 = load i32, ptr %i, align 4109 %cmp = icmp slt i32 %2, 10110 br i1 %cmp, label %while.body, label %while.end111 112while.body: ; preds = %while.cond113 %3 = load i32, ptr %i, align 4114 store i32 %3, ptr %val, align 4115 %4 = load i32, ptr %val, align 4116 %cmp1 = icmp sgt i32 %4, 5117 br i1 %cmp1, label %if.then, label %if.end118 119if.then: ; preds = %while.body120 br label %while.end121 122if.end: ; preds = %while.body123 %5 = load i32, ptr %val, align 4124 %cmp2 = icmp sgt i32 %5, 6125 br i1 %cmp2, label %if.then3, label %if.end4126 127if.then3: ; preds = %if.end128 br label %while.end129 130if.end4: ; preds = %if.end131 br label %while.cond132 133while.end: ; preds = %if.then3, %if.then, %while.cond134 br label %while.cond5135 136while.cond5: ; preds = %while.end137 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]138 br label %while.body6139 140while.body6: ; preds = %while.cond5141 %7 = load i32, ptr %i, align 4142 %inc = add nsw i32 %7, 1143 store i32 %inc, ptr %i, align 4144 br label %while.cond7145 146while.cond7: ; preds = %while.body6147 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]148 %9 = load i32, ptr %i, align 4149 %cmp8 = icmp slt i32 %9, 20150 br i1 %cmp8, label %while.body9, label %while.end10151 152while.body9: ; preds = %while.cond7153 %10 = load i32, ptr %i, align 4154 store i32 %10, ptr %val, align 4155 br label %while.end10156 157while.end10: ; preds = %while.body9, %while.cond7158 %11 = load i32, ptr %i, align 4159 %dec = add nsw i32 %11, -1160 store i32 %dec, ptr %i, align 4161 br label %while.end11162 163while.end11: ; preds = %while.end10164 ret void165}166 167; Function Attrs: convergent norecurse168define void @main.1() #2 {169entry:170 call void @main()171 ret void172}173 174; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)175declare token @llvm.experimental.convergence.loop() #1176 177attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }178attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }179attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }180 181!llvm.module.flags = !{!0, !1, !2}182 183 184!0 = !{i32 1, !"wchar_size", i32 4}185!1 = !{i32 4, !"dx.disable_optimizations", i32 1}186!2 = !{i32 7, !"frame-pointer", i32 2}187 188 189