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 fn() { return true; }
12 ; // Use in control flow
15 ; // Operand with side effects
16 ; if (fn() || fn()) val++;
17 ; if (a || fn()) val++;
18 ; if (fn() || b) val++;
22 ; [numthreads(1, 1, 1)]
27 ; CHECK: %[[#func_10:]] = OpFunction %[[#uint:]] DontInline %[[#]]
28 ; CHECK: %[[#bb52:]] = OpLabel
29 ; CHECK: OpReturnValue %[[#]]
30 ; CHECK: OpFunctionEnd
31 ; CHECK: %[[#func_11:]] = OpFunction %[[#uint:]] DontInline %[[#]]
32 ; CHECK: %[[#bb53:]] = OpLabel
33 ; CHECK: OpSelectionMerge %[[#bb54:]] None
34 ; CHECK: OpBranchConditional %[[#]] %[[#bb55:]] %[[#bb56:]]
35 ; CHECK: %[[#bb55:]] = OpLabel
36 ; CHECK: OpSelectionMerge %[[#bb57:]] None
37 ; CHECK: OpBranchConditional %[[#]] %[[#bb57:]] %[[#bb58:]]
38 ; CHECK: %[[#bb56:]] = OpLabel
39 ; CHECK: %[[#bb58:]] = OpLabel
40 ; CHECK: OpBranchConditional %[[#]] %[[#bb57:]] %[[#bb59:]]
41 ; CHECK: %[[#bb59:]] = OpLabel
42 ; CHECK: OpBranch %[[#bb57:]]
43 ; CHECK: %[[#bb57:]] = OpLabel
44 ; CHECK: OpBranchConditional %[[#]] %[[#bb60:]] %[[#bb54:]]
45 ; CHECK: %[[#bb60:]] = OpLabel
46 ; CHECK: OpBranch %[[#bb54:]]
47 ; CHECK: %[[#bb54:]] = OpLabel
48 ; CHECK: OpSelectionMerge %[[#bb61:]] None
49 ; CHECK: OpBranchConditional %[[#]] %[[#bb62:]] %[[#bb63:]]
50 ; CHECK: %[[#bb62:]] = OpLabel
51 ; CHECK: OpSelectionMerge %[[#bb64:]] None
52 ; CHECK: OpBranchConditional %[[#]] %[[#bb64:]] %[[#bb65:]]
53 ; CHECK: %[[#bb63:]] = OpLabel
54 ; CHECK: %[[#bb65:]] = OpLabel
55 ; CHECK: OpBranchConditional %[[#]] %[[#bb64:]] %[[#bb66:]]
56 ; CHECK: %[[#bb66:]] = OpLabel
57 ; CHECK: OpBranch %[[#bb64:]]
58 ; CHECK: %[[#bb64:]] = OpLabel
59 ; CHECK: OpBranchConditional %[[#]] %[[#bb67:]] %[[#bb61:]]
60 ; CHECK: %[[#bb67:]] = OpLabel
61 ; CHECK: OpBranch %[[#bb61:]]
62 ; CHECK: %[[#bb61:]] = OpLabel
63 ; CHECK: OpSelectionMerge %[[#bb68:]] None
64 ; CHECK: OpBranchConditional %[[#]] %[[#bb69:]] %[[#bb70:]]
65 ; CHECK: %[[#bb69:]] = OpLabel
66 ; CHECK: OpSelectionMerge %[[#bb71:]] None
67 ; CHECK: OpBranchConditional %[[#]] %[[#bb71:]] %[[#bb72:]]
68 ; CHECK: %[[#bb70:]] = OpLabel
69 ; CHECK: %[[#bb72:]] = OpLabel
70 ; CHECK: OpBranchConditional %[[#]] %[[#bb71:]] %[[#bb73:]]
71 ; CHECK: %[[#bb73:]] = OpLabel
72 ; CHECK: OpBranch %[[#bb71:]]
73 ; CHECK: %[[#bb71:]] = OpLabel
74 ; CHECK: OpBranchConditional %[[#]] %[[#bb74:]] %[[#bb68:]]
75 ; CHECK: %[[#bb74:]] = OpLabel
76 ; CHECK: OpBranch %[[#bb68:]]
77 ; CHECK: %[[#bb68:]] = OpLabel
78 ; CHECK: OpSelectionMerge %[[#bb75:]] None
79 ; CHECK: OpBranchConditional %[[#]] %[[#bb76:]] %[[#bb77:]]
80 ; CHECK: %[[#bb76:]] = OpLabel
81 ; CHECK: OpSelectionMerge %[[#bb78:]] None
82 ; CHECK: OpBranchConditional %[[#]] %[[#bb78:]] %[[#bb79:]]
83 ; CHECK: %[[#bb77:]] = OpLabel
84 ; CHECK: %[[#bb79:]] = OpLabel
85 ; CHECK: OpBranchConditional %[[#]] %[[#bb78:]] %[[#bb80:]]
86 ; CHECK: %[[#bb80:]] = OpLabel
87 ; CHECK: OpBranch %[[#bb78:]]
88 ; CHECK: %[[#bb78:]] = OpLabel
89 ; CHECK: OpBranchConditional %[[#]] %[[#bb81:]] %[[#bb75:]]
90 ; CHECK: %[[#bb81:]] = OpLabel
91 ; CHECK: OpBranch %[[#bb75:]]
92 ; CHECK: %[[#bb75:]] = OpLabel
93 ; CHECK: OpReturnValue %[[#]]
94 ; CHECK: OpFunctionEnd
95 ; CHECK: %[[#func_48:]] = OpFunction %[[#void:]] DontInline %[[#]]
96 ; CHECK: %[[#bb82:]] = OpLabel
98 ; CHECK: OpFunctionEnd
99 ; CHECK: %[[#func_50:]] = OpFunction %[[#void:]] None %[[#]]
100 ; CHECK: %[[#bb83:]] = OpLabel
102 ; CHECK: OpFunctionEnd
104 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
105 target triple = "spirv-unknown-vulkan1.3-compute"
107 ; Function Attrs: convergent noinline norecurse nounwind optnone
108 define spir_func noundef i32 @_Z2fnv() #0 {
110 %0 = call token @llvm.experimental.convergence.entry()
114 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
115 declare token @llvm.experimental.convergence.entry() #1
117 ; Function Attrs: convergent noinline norecurse nounwind optnone
118 define spir_func noundef i32 @_Z7processv() #0 {
120 %0 = call token @llvm.experimental.convergence.entry()
121 %a = alloca i32, align 4
122 %b = alloca i32, align 4
123 %val = alloca i32, align 4
124 store i32 0, ptr %a, align 4
125 store i32 0, ptr %b, align 4
126 store i32 0, ptr %val, align 4
127 %1 = load i32, ptr %a, align 4
128 %tobool = icmp ne i32 %1, 0
129 br i1 %tobool, label %if.then, label %lor.lhs.false
131 lor.lhs.false: ; preds = %entry
132 %2 = load i32, ptr %b, align 4
133 %tobool1 = icmp ne i32 %2, 0
134 br i1 %tobool1, label %if.then, label %if.end
136 if.then: ; preds = %lor.lhs.false, %entry
137 %3 = load i32, ptr %val, align 4
138 %inc = add nsw i32 %3, 1
139 store i32 %inc, ptr %val, align 4
142 if.end: ; preds = %if.then, %lor.lhs.false
143 %call2 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]
144 %tobool3 = icmp ne i32 %call2, 0
145 br i1 %tobool3, label %if.then7, label %lor.lhs.false4
147 lor.lhs.false4: ; preds = %if.end
148 %call5 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]
149 %tobool6 = icmp ne i32 %call5, 0
150 br i1 %tobool6, label %if.then7, label %if.end9
152 if.then7: ; preds = %lor.lhs.false4, %if.end
153 %4 = load i32, ptr %val, align 4
154 %inc8 = add nsw i32 %4, 1
155 store i32 %inc8, ptr %val, align 4
158 if.end9: ; preds = %if.then7, %lor.lhs.false4
159 %5 = load i32, ptr %a, align 4
160 %tobool10 = icmp ne i32 %5, 0
161 br i1 %tobool10, label %if.then14, label %lor.lhs.false11
163 lor.lhs.false11: ; preds = %if.end9
164 %call12 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]
165 %tobool13 = icmp ne i32 %call12, 0
166 br i1 %tobool13, label %if.then14, label %if.end16
168 if.then14: ; preds = %lor.lhs.false11, %if.end9
169 %6 = load i32, ptr %val, align 4
170 %inc15 = add nsw i32 %6, 1
171 store i32 %inc15, ptr %val, align 4
174 if.end16: ; preds = %if.then14, %lor.lhs.false11
175 %call17 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]
176 %tobool18 = icmp ne i32 %call17, 0
177 br i1 %tobool18, label %if.then21, label %lor.lhs.false19
179 lor.lhs.false19: ; preds = %if.end16
180 %7 = load i32, ptr %b, align 4
181 %tobool20 = icmp ne i32 %7, 0
182 br i1 %tobool20, label %if.then21, label %if.end23
184 if.then21: ; preds = %lor.lhs.false19, %if.end16
185 %8 = load i32, ptr %val, align 4
186 %inc22 = add nsw i32 %8, 1
187 store i32 %inc22, ptr %val, align 4
190 if.end23: ; preds = %if.then21, %lor.lhs.false19
191 %9 = load i32, ptr %val, align 4
195 ; Function Attrs: convergent noinline norecurse nounwind optnone
196 define internal spir_func void @main() #0 {
198 %0 = call token @llvm.experimental.convergence.entry()
199 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
203 ; Function Attrs: convergent norecurse
204 define void @main.1() #2 {
210 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
211 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
212 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
213 attributes #3 = { convergent }
215 !llvm.module.flags = !{!0, !1, !2}
218 !0 = !{i32 1, !"wchar_size", i32 4}
219 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
220 !2 = !{i32 7, !"frame-pointer", i32 2}