1 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
2 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
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 ; CHECK-DAG: OpName %[[#process:]] "_Z7processv"
8 ; CHECK-DAG: OpName %[[#val:]] "val"
9 ; CHECK-DAG: OpName %[[#i:]] "i"
11 ; CHECK-DAG: %[[#int_ty:]] = OpTypeInt 32 0
12 ; CHECK-DAG: %[[#int_pfty:]] = OpTypePointer Function %[[#int_ty]]
13 ; CHECK-DAG: %[[#false:]] = OpConstantFalse
16 ; CHECK: %[[#process]] = OpFunction %[[#]] DontInline %[[#]]
17 define spir_func noundef i32 @_Z7processv() #0 {
19 %0 = call token @llvm.experimental.convergence.entry()
21 ; CHECK-DAG: %[[#val]] = OpVariable %[[#int_pfty]] Function
22 ; CHECK-DAG: %[[#i]] = OpVariable %[[#int_pfty]] Function
23 %val = alloca i32, align 4
24 %i = alloca i32, align 4
25 store i32 0, ptr %val, align 4
26 store i32 0, ptr %i, align 4
28 ; CHECK: OpBranch %[[#for_cond:]]
30 for.cond: ; preds = %for.inc, %entry
31 ; CHECK: %[[#for_cond]] = OpLabel
32 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
33 %2 = load i32, ptr %i, align 4
34 %cmp = icmp slt i32 %2, 10
36 ; CHECK: OpLoopMerge %[[#for_end:]] %[[#for_inc:]]
37 ; CHECK: OpBranchConditional %[[#]] %[[#for_body:]] %[[#for_end]]
38 br i1 %cmp, label %for.body, label %for.end
40 for.body: ; preds = %for.cond
41 %3 = load i32, ptr %i, align 4
42 store i32 %3, ptr %val, align 4
44 ; CHECK: %[[#for_body]] = OpLabel
45 ; CHECK: OpBranch %[[#for_inc]]
47 for.inc: ; preds = %for.body
48 %4 = load i32, ptr %i, align 4
49 %inc = add nsw i32 %4, 1
50 store i32 %inc, ptr %i, align 4
52 ; CHECK: %[[#for_inc]] = OpLabel
53 ; CHECK: OpBranch %[[#for_cond]]
55 for.end: ; preds = %for.cond
57 ; CHECK: %[[#for_end]] = OpLabel
58 ; CHECK: OpBranch %[[#for_cond1:]]
60 for.cond1: ; preds = %for.cond1, %for.end
61 %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
62 store i32 0, ptr %val, align 4
64 ; CHECK: %[[#for_cond1]] = OpLabel
65 ; CHECK: OpLoopMerge %[[#unreachable:]] %[[#for_cond1]]
66 ; CHECK: OpBranchConditional %[[#false]] %[[#unreachable]] %[[#for_cond1]]
68 ; CHECK: %[[#unreachable]] = OpLabel
69 ; CHECK-NEXT: OpUnreachable
72 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
73 declare token @llvm.experimental.convergence.entry() #1
75 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
76 declare token @llvm.experimental.convergence.loop() #1
78 ; Function Attrs: convergent noinline norecurse nounwind optnone
79 define internal spir_func void @main() #2 {
81 %0 = call token @llvm.experimental.convergence.entry()
82 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ]
86 ; Function Attrs: convergent norecurse
87 define void @main.1() #3 {
93 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
94 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
95 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
96 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
97 attributes #4 = { convergent }
99 !llvm.module.flags = !{!0, !1, !2}
101 !0 = !{i32 1, !"wchar_size", i32 4}
102 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
103 !2 = !{i32 7, !"frame-pointer", i32 2}