141 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; //////////////////////////13; //// Basic while loop ////14; //////////////////////////15; while (i < 10) {16; val = i;17; }18;19; //////////////////////////20; //// infinite loop ////21; //////////////////////////22; while (true) {23; val = 0;24; }25;26; //////////////////////////27; //// Null Body ////28; //////////////////////////29; while (val < 20)30; ;31;32; ////////////////////////////////////////////////////////////////33; //// Condition variable has VarDecl ////34; //// foo() returns an integer which must be cast to boolean ////35; ////////////////////////////////////////////////////////////////36; while (int a = foo()) {37; val = a;38; }39;40; }41 42; CHECK: %[[#func_11:]] = OpFunction %[[#uint:]] DontInline %[[#]]43; CHECK: %[[#bb20:]] = OpLabel44; CHECK: OpReturnValue %[[#]]45; CHECK: OpFunctionEnd46 47; CHECK: %[[#func_12:]] = OpFunction %[[#void:]] DontInline %[[#]]48; CHECK: %[[#bb21:]] = OpLabel49; CHECK: OpBranch %[[#bb22:]]50; CHECK: %[[#bb22]] = OpLabel51; CHECK: OpLoopMerge %[[#bb23:]] %[[#bb24:]] None52; CHECK: OpBranchConditional %[[#]] %[[#bb24]] %[[#bb23]]53; CHECK: %[[#bb23]] = OpLabel54; CHECK: OpBranch %[[#bb25:]]55; CHECK: %[[#bb25]] = OpLabel56; CHECK: OpLoopMerge %[[#bb26:]] %[[#bb27:]] None57; CHECK: OpBranchConditional %[[#]] %[[#bb26]] %[[#bb27]]58; CHECK: %[[#bb27]] = OpLabel59; CHECK: OpBranch %[[#bb25]]60; CHECK: %[[#bb26]] = OpLabel61; CHECK-NEXT: OpUnreachable62; CHECK: %[[#bb24]] = OpLabel63; CHECK: OpBranch %[[#bb22]]64; CHECK: OpFunctionEnd65 66; CHECK: %[[#func_18:]] = OpFunction %[[#void:]] None %[[#]]67; CHECK: %[[#bb28:]] = OpLabel68; CHECK: OpReturn69; CHECK: OpFunctionEnd70 71 72 73target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"74target triple = "spirv-unknown-vulkan1.3-compute"75 76; Function Attrs: convergent noinline norecurse nounwind optnone77define spir_func noundef i32 @_Z3foov() #0 {78entry:79 %0 = call token @llvm.experimental.convergence.entry()80 ret i32 181}82 83; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)84declare token @llvm.experimental.convergence.entry() #185 86; Function Attrs: convergent noinline norecurse nounwind optnone87define internal spir_func void @main() #0 {88entry:89 %0 = call token @llvm.experimental.convergence.entry()90 %val = alloca i32, align 491 %i = alloca i32, align 492 store i32 0, ptr %val, align 493 store i32 0, ptr %i, align 494 br label %while.cond95 96while.cond: ; preds = %while.body, %entry97 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]98 %2 = load i32, ptr %i, align 499 %cmp = icmp slt i32 %2, 10100 br i1 %cmp, label %while.body, label %while.end101 102while.body: ; preds = %while.cond103 %3 = load i32, ptr %i, align 4104 store i32 %3, ptr %val, align 4105 br label %while.cond106 107while.end: ; preds = %while.cond108 br label %while.cond1109 110while.cond1: ; preds = %while.body2, %while.end111 %4 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]112 br label %while.body2113 114while.body2: ; preds = %while.cond1115 store i32 0, ptr %val, align 4116 br label %while.cond1117}118 119; Function Attrs: convergent norecurse120define void @main.1() #2 {121entry:122 call void @main()123 ret void124}125 126; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)127declare token @llvm.experimental.convergence.loop() #1128 129attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }130attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }131attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }132 133!llvm.module.flags = !{!0, !1, !2}134 135 136!0 = !{i32 1, !"wchar_size", i32 4}137!1 = !{i32 4, !"dx.disable_optimizations", i32 1}138!2 = !{i32 7, !"frame-pointer", i32 2}139 140 141