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 %}
9 ; // Both then and else
37 ; [numthreads(1, 1, 1)]
42 ; CHECK: %[[#func_10:]] = OpFunction %[[#uint:]] DontInline %[[#]]
43 ; CHECK: %[[#bb34:]] = OpLabel
44 ; CHECK: OpSelectionMerge %[[#bb35:]] None
45 ; CHECK: OpBranchConditional %[[#]] %[[#bb36:]] %[[#bb37:]]
46 ; CHECK: %[[#bb36:]] = OpLabel
47 ; CHECK: OpBranch %[[#bb35:]]
48 ; CHECK: %[[#bb37:]] = OpLabel
49 ; CHECK: OpBranch %[[#bb35:]]
50 ; CHECK: %[[#bb35:]] = OpLabel
51 ; CHECK: OpSelectionMerge %[[#bb38:]] None
52 ; CHECK: OpBranchConditional %[[#]] %[[#bb39:]] %[[#bb38:]]
53 ; CHECK: %[[#bb39:]] = OpLabel
54 ; CHECK: OpBranch %[[#bb38:]]
55 ; CHECK: %[[#bb38:]] = OpLabel
56 ; CHECK: OpSelectionMerge %[[#bb40:]] None
57 ; CHECK: OpBranchConditional %[[#]] %[[#bb40:]] %[[#bb41:]]
58 ; CHECK: %[[#bb41:]] = OpLabel
59 ; CHECK: OpBranch %[[#bb40:]]
60 ; CHECK: %[[#bb40:]] = OpLabel
61 ; CHECK: OpBranch %[[#bb42:]]
62 ; CHECK: %[[#bb42:]] = OpLabel
63 ; CHECK: OpSelectionMerge %[[#bb43:]] None
64 ; CHECK: OpBranchConditional %[[#]] %[[#bb44:]] %[[#bb43:]]
65 ; CHECK: %[[#bb44:]] = OpLabel
66 ; CHECK: OpBranch %[[#bb43:]]
67 ; CHECK: %[[#bb43:]] = OpLabel
68 ; CHECK: OpReturnValue %[[#]]
69 ; CHECK: OpFunctionEnd
70 ; CHECK: %[[#func_30:]] = OpFunction %[[#void:]] DontInline %[[#]]
71 ; CHECK: %[[#bb45:]] = OpLabel
73 ; CHECK: OpFunctionEnd
74 ; CHECK: %[[#func_32:]] = OpFunction %[[#void:]] None %[[#]]
75 ; CHECK: %[[#bb46:]] = OpLabel
77 ; CHECK: OpFunctionEnd
79 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
80 target triple = "spirv-unknown-vulkan1.3-compute"
82 ; Function Attrs: convergent noinline norecurse nounwind optnone
83 define spir_func noundef i32 @_Z7processv() #0 {
85 %0 = call token @llvm.experimental.convergence.entry()
86 %c = alloca i32, align 4
87 %val = alloca i32, align 4
88 %d = alloca i32, align 4
89 store i32 0, ptr %c, align 4
90 store i32 0, ptr %val, align 4
91 %1 = load i32, ptr %c, align 4
92 %tobool = icmp ne i32 %1, 0
93 br i1 %tobool, label %if.then, label %if.else
95 if.then: ; preds = %entry
96 %2 = load i32, ptr %val, align 4
97 %add = add nsw i32 %2, 1
98 store i32 %add, ptr %val, align 4
101 if.else: ; preds = %entry
102 %3 = load i32, ptr %val, align 4
103 %add1 = add nsw i32 %3, 2
104 store i32 %add1, ptr %val, align 4
107 if.end: ; preds = %if.else, %if.then
108 %4 = load i32, ptr %c, align 4
109 %tobool2 = icmp ne i32 %4, 0
110 br i1 %tobool2, label %if.then3, label %if.end4
112 if.then3: ; preds = %if.end
113 store i32 1, ptr %val, align 4
116 if.end4: ; preds = %if.then3, %if.end
117 %5 = load i32, ptr %c, align 4
118 %tobool5 = icmp ne i32 %5, 0
119 br i1 %tobool5, label %if.then6, label %if.else7
121 if.then6: ; preds = %if.end4
124 if.else7: ; preds = %if.end4
125 store i32 2, ptr %val, align 4
128 if.end8: ; preds = %if.else7, %if.then6
129 %6 = load i32, ptr %c, align 4
130 %tobool9 = icmp ne i32 %6, 0
131 br i1 %tobool9, label %if.then10, label %if.end11
133 if.then10: ; preds = %if.end8
136 if.end11: ; preds = %if.then10, %if.end8
137 %7 = load i32, ptr %val, align 4
138 store i32 %7, ptr %d, align 4
139 %8 = load i32, ptr %d, align 4
140 %tobool12 = icmp ne i32 %8, 0
141 br i1 %tobool12, label %if.then13, label %if.end14
143 if.then13: ; preds = %if.end11
144 store i32 1, ptr %c, align 4
147 if.end14: ; preds = %if.then13, %if.end11
148 %9 = load i32, ptr %val, align 4
152 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
153 declare token @llvm.experimental.convergence.entry() #1
155 ; Function Attrs: convergent noinline norecurse nounwind optnone
156 define internal spir_func void @main() #0 {
158 %0 = call token @llvm.experimental.convergence.entry()
159 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
163 ; Function Attrs: convergent norecurse
164 define void @main.1() #2 {
170 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
171 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
172 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
173 attributes #3 = { convergent }
175 !llvm.module.flags = !{!0, !1, !2}
178 !0 = !{i32 1, !"wchar_size", i32 4}
179 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
180 !2 = !{i32 7, !"frame-pointer", i32 2}