1 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s --match-full-lines
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
4 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
5 target triple = "spirv-unknown-vulkan1.3-compute"
7 define spir_func noundef i32 @_Z3foov() #0 {
9 %0 = call token @llvm.experimental.convergence.entry()
13 define internal spir_func void @main() #2 {
14 ; CHECK: %[[#entry:]] = OpLabel
15 ; CHECK: OpBranch %[[#do_header:]]
17 %0 = call token @llvm.experimental.convergence.entry()
18 %var = alloca i32, align 4
21 ; Here a the loop header had to be split in two:
22 ; - 1 header for the loop
23 ; - 1 header for the condition.
24 ; In SPIR-V, a loop header cannot directly
25 ; CHECK: %[[#do_header:]] = OpLabel
26 ; CHECK: OpLoopMerge %[[#do_merge:]] %[[#do_latch:]] None
27 ; CHECK: OpBranch %[[#new_header:]]
29 ; CHECK: %[[#new_header]] = OpLabel
30 ; CHECK: OpSelectionMerge %[[#if_merge:]] None
31 ; CHECK: OpBranchConditional %[[#]] %[[#if_then:]] %[[#if_end:]]
33 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
35 br i1 true, label %if.then, label %if.end
37 ; CHECK: %[[#if_then]] = OpLabel
38 ; CHECK: OpBranch %[[#if_merge]]
43 ; CHECK: %[[#if_end]] = OpLabel
44 ; CHECK: OpBranch %[[#if_merge]]
49 ; CHECK: %[[#if_merge]] = OpLabel
50 ; CHECK: OpBranchConditional %[[#]] %[[#do_latch]] %[[#do_merge]]
52 ; CHECK: %[[#do_latch]] = OpLabel
53 ; CHECK: OpBranch %[[#do_header]]
56 br i1 true, label %do_header, label %do.end
58 ; CHECK: %[[#do_merge]] = OpLabel
59 ; CHECK: OpBranch %[[#do2_header:]]
64 ; CHECK: %[[#do2_header]] = OpLabel
65 ; CHECK: OpLoopMerge %[[#do2_merge:]] %[[#do2_continue:]] None
66 ; CHECK: OpBranch %[[#do3_header:]]
68 %6 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
72 ; CHECK: %[[#do3_header]] = OpLabel
73 ; CHECK: OpLoopMerge %[[#do3_merge:]] %[[#do3_continue:]] None
74 ; CHECK: OpBranch %[[#do3_body:]]
76 %8 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %6) ]
78 br label %do3_continue
80 ; CHECK: %[[#do3_body]] = OpLabel
81 ; CHECK: OpBranchConditional %[[#]] %[[#do3_continue]] %[[#do3_merge]]
83 ; CHECK: %[[#do3_continue]] = OpLabel
84 ; CHECK: OpBranch %[[#do3_header]]
87 br i1 true, label %do3_header, label %do3_merge
89 ; CHECK: %[[#do3_merge]] = OpLabel
90 ; CHECK: OpBranch %[[#do2_new_latch:]]
93 br label %do2_continue
95 ; CHECK: %[[#do2_new_latch]] = OpLabel
96 ; CHECK: OpBranchConditional %[[#]] %[[#do2_continue]] %[[#do2_merge]]
98 ; CHECK: %[[#do2_continue]] = OpLabel
99 ; CHECK: OpBranch %[[#do2_header]]
101 store i32 0, ptr %var
102 br i1 true, label %do2_header, label %do2_merge
104 ; CHECK: %[[#do2_merge]] = OpLabel
110 declare token @llvm.experimental.convergence.entry() #1
111 declare token @llvm.experimental.convergence.loop() #1
113 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
114 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
115 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
116 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
118 !llvm.module.flags = !{!0, !1, !2}
120 !0 = !{i32 1, !"wchar_size", i32 4}
121 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
122 !2 = !{i32 7, !"frame-pointer", i32 2}