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 %}
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-vulkan-compute"
7 ; Function Attrs: convergent noinline nounwind optnone
8 define spir_func noundef i32 @fn() #4 {
10 %0 = call token @llvm.experimental.convergence.entry()
14 ; Function Attrs: convergent noinline nounwind optnone
15 define spir_func noundef i32 @fn1() #4 {
17 %0 = call token @llvm.experimental.convergence.entry()
21 ; Function Attrs: convergent noinline nounwind optnone
22 define spir_func noundef i32 @fn2() #4 {
24 %0 = call token @llvm.experimental.convergence.entry()
29 ; CHECK-DAG: OpName %[[#reg_0:]] "cond.reg2mem"
30 ; CHECK-DAG: OpName %[[#reg_1:]] "cond9.reg2mem"
32 define internal spir_func void @main() #0 {
33 ; CHECK: OpSelectionMerge %[[#cond1_merge:]] None
34 ; CHECK: OpBranchConditional %[[#]] %[[#cond1_true:]] %[[#cond1_false:]]
36 %0 = call token @llvm.experimental.convergence.entry()
37 %a = alloca i32, align 4
38 %b = alloca i32, align 4
39 br i1 true, label %cond1_true, label %cond1_false
41 ; CHECK: %[[#cond1_true]] = OpLabel
42 ; CHECK: OpStore %[[#reg_0]] %[[#]]
43 ; CHECK: OpBranch %[[#cond1_merge]]
45 %2 = load i32, ptr %a, align 4
48 ; CHECK: %[[#cond1_false]] = OpLabel
49 ; CHECK: OpStore %[[#reg_0]] %[[#]]
50 ; CHECK: OpBranch %[[#cond1_merge]]
52 %3 = load i32, ptr %b, align 4
55 ; CHECK: %[[#cond1_merge]] = OpLabel
56 ; CHECK: %[[#tmp:]] = OpLoad %[[#]] %[[#reg_0]]
57 ; CHECK: %[[#cond:]] = OpINotEqual %[[#]] %[[#tmp]] %[[#]]
58 ; CHECK: OpSelectionMerge %[[#cond2_merge:]] None
59 ; CHECK: OpBranchConditional %[[#cond]] %[[#cond2_true:]] %[[#cond2_merge]]
61 %cond = phi i32 [ %2, %cond1_true ], [ %3, %cond1_false ]
62 %tobool1 = icmp ne i32 %cond, 0
63 br i1 %tobool1, label %cond2_true, label %cond2_merge
65 ; CHECK: %[[#cond2_true]] = OpLabel
66 ; CHECK: OpBranch %[[#cond2_merge]]
71 ; CHECK: %[[#cond2_merge]] = OpLabel
72 ; CHECK: OpFunctionCall
73 ; CHECK: OpSelectionMerge %[[#cond3_merge:]] None
74 ; CHECK: OpBranchConditional %[[#]] %[[#cond3_true:]] %[[#cond3_false:]]
76 %call2 = call spir_func noundef i32 @fn() #4 [ "convergencectrl"(token %0) ]
77 br i1 true, label %cond3_true, label %cond3_false
79 ; CHECK: %[[#cond3_true]] = OpLabel
80 ; CHECK: OpFunctionCall
81 ; CHECK: OpStore %[[#reg_1]] %[[#]]
82 ; CHECK: OpBranch %[[#cond3_merge]]
84 %call5 = call spir_func noundef i32 @fn1() #4 [ "convergencectrl"(token %0) ]
87 ; CHECK: %[[#cond3_false]] = OpLabel
88 ; CHECK: OpFunctionCall
89 ; CHECK: OpStore %[[#reg_1]] %[[#]]
90 ; CHECK: OpBranch %[[#cond3_merge]]
92 %call7 = call spir_func noundef i32 @fn2() #4 [ "convergencectrl"(token %0) ]
95 ; CHECK: %[[#cond3_merge]] = OpLabel
96 ; CHECK: %[[#tmp:]] = OpLoad %[[#]] %[[#reg_1]]
97 ; CHECK: %[[#cond:]] = OpINotEqual %[[#]] %[[#tmp]] %[[#]]
98 ; CHECK: OpSelectionMerge %[[#cond4_merge:]] None
99 ; CHECK: OpBranchConditional %[[#cond]] %[[#cond4_true:]] %[[#cond4_merge]]
101 %cond9 = phi i32 [ %call5, %cond3_true ], [ %call7, %cond3_false ]
102 %tobool10 = icmp ne i32 %cond9, 0
103 br i1 %tobool10, label %cond4_true, label %cond4_merge
105 ; CHECK: %[[#cond4_true]] = OpLabel
106 ; CHECK: OpBranch %[[#cond4_merge]]
109 br label %cond4_merge
111 ; CHECK: %[[#cond4_merge]] = OpLabel
117 declare token @llvm.experimental.convergence.entry() #2
119 attributes #0 = { convergent noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
120 attributes #1 = { convergent norecurse "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
121 attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
122 attributes #3 = { convergent }
123 attributes #4 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
125 !llvm.module.flags = !{!0, !1}
127 !0 = !{i32 1, !"wchar_size", i32 4}
128 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}