1 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
5 ; int foo() { return true; }
7 ; [numthreads(1, 1, 1)]
12 ; //////////////////////////
13 ; //// Basic while loop ////
14 ; //////////////////////////
19 ; //////////////////////////
20 ; //// infinite loop ////
21 ; //////////////////////////
26 ; //////////////////////////
28 ; //////////////////////////
32 ; ////////////////////////////////////////////////////////////////
33 ; //// Condition variable has VarDecl ////
34 ; //// foo() returns an integer which must be cast to boolean ////
35 ; ////////////////////////////////////////////////////////////////
36 ; while (int a = foo()) {
42 ; CHECK: %[[#func_11:]] = OpFunction %[[#uint:]] DontInline %[[#]]
43 ; CHECK: %[[#bb20:]] = OpLabel
44 ; CHECK: OpReturnValue %[[#]]
45 ; CHECK: OpFunctionEnd
46 ; CHECK: %[[#func_12:]] = OpFunction %[[#void:]] DontInline %[[#]]
47 ; CHECK: %[[#bb21:]] = OpLabel
48 ; CHECK: OpBranch %[[#bb22:]]
49 ; CHECK: %[[#bb22:]] = OpLabel
50 ; CHECK: OpLoopMerge %[[#bb23:]] %[[#bb24:]] None
51 ; CHECK: OpBranchConditional %[[#]] %[[#bb24:]] %[[#bb23:]]
52 ; CHECK: %[[#bb24:]] = OpLabel
53 ; CHECK: OpBranch %[[#bb22:]]
54 ; CHECK: %[[#bb23:]] = OpLabel
55 ; CHECK: OpBranch %[[#bb25:]]
56 ; CHECK: %[[#bb25:]] = OpLabel
57 ; CHECK: OpLoopMerge %[[#bb26:]] %[[#bb27:]] None
58 ; CHECK: OpBranchConditional %[[#]] %[[#bb26:]] %[[#bb27:]]
59 ; CHECK: %[[#bb27:]] = OpLabel
60 ; CHECK: OpBranch %[[#bb25:]]
61 ; CHECK: %[[#bb26:]] = OpLabel
62 ; CHECK: OpFunctionEnd
63 ; CHECK: %[[#func_18:]] = OpFunction %[[#void:]] None %[[#]]
64 ; CHECK: %[[#bb28:]] = OpLabel
66 ; CHECK: OpFunctionEnd
70 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
71 target triple = "spirv-unknown-vulkan1.3-compute"
73 ; Function Attrs: convergent noinline norecurse nounwind optnone
74 define spir_func noundef i32 @_Z3foov() #0 {
76 %0 = call token @llvm.experimental.convergence.entry()
80 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
81 declare token @llvm.experimental.convergence.entry() #1
83 ; Function Attrs: convergent noinline norecurse nounwind optnone
84 define internal spir_func void @main() #0 {
86 %0 = call token @llvm.experimental.convergence.entry()
87 %val = alloca i32, align 4
88 %i = alloca i32, align 4
89 store i32 0, ptr %val, align 4
90 store i32 0, ptr %i, align 4
93 while.cond: ; preds = %while.body, %entry
94 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
95 %2 = load i32, ptr %i, align 4
96 %cmp = icmp slt i32 %2, 10
97 br i1 %cmp, label %while.body, label %while.end
99 while.body: ; preds = %while.cond
100 %3 = load i32, ptr %i, align 4
101 store i32 %3, ptr %val, align 4
104 while.end: ; preds = %while.cond
105 br label %while.cond1
107 while.cond1: ; preds = %while.body2, %while.end
108 %4 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
109 br label %while.body2
111 while.body2: ; preds = %while.cond1
112 store i32 0, ptr %val, align 4
113 br label %while.cond1
116 ; Function Attrs: convergent norecurse
117 define void @main.1() #2 {
123 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
124 declare token @llvm.experimental.convergence.loop() #1
126 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
127 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
128 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
130 !llvm.module.flags = !{!0, !1, !2}
133 !0 = !{i32 1, !"wchar_size", i32 4}
134 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
135 !2 = !{i32 7, !"frame-pointer", i32 2}