1 ; RUN: %if spirv-tools %{ llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | spirv-as --preserve-numeric-ids - -o - | spirv-val %}
6 ; int val=0, i=0, j=0, k=0;
23 ; return val + i + j + k;
26 ; [numthreads(1, 1, 1)]
31 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
32 target triple = "spirv-unknown-vulkan1.3-compute"
34 ; Function Attrs: convergent noinline nounwind optnone
35 define spir_func noundef i32 @_Z7processv() #0 {
37 %0 = call token @llvm.experimental.convergence.entry()
38 %val = alloca i32, align 4
39 %i = alloca i32, align 4
40 %j = alloca i32, align 4
41 %k = alloca i32, align 4
42 store i32 0, ptr %val, align 4
43 store i32 0, ptr %i, align 4
44 store i32 0, ptr %j, align 4
45 store i32 0, ptr %k, align 4
48 do.body: ; preds = %do.cond8, %entry
49 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
50 %2 = load i32, ptr %val, align 4
51 %3 = load i32, ptr %i, align 4
52 %add = add nsw i32 %2, %3
53 store i32 %add, ptr %val, align 4
56 do.body1: ; preds = %do.cond4, %do.body
57 %4 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
60 do.body2: ; preds = %do.cond, %do.body1
61 %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %4) ]
62 %6 = load i32, ptr %k, align 4
63 %inc = add nsw i32 %6, 1
64 store i32 %inc, ptr %k, align 4
67 do.cond: ; preds = %do.body2
68 %7 = load i32, ptr %k, align 4
69 %cmp = icmp slt i32 %7, 30
70 br i1 %cmp, label %do.body2, label %do.end
72 do.end: ; preds = %do.cond
73 %8 = load i32, ptr %j, align 4
74 %inc3 = add nsw i32 %8, 1
75 store i32 %inc3, ptr %j, align 4
78 do.cond4: ; preds = %do.end
79 %9 = load i32, ptr %j, align 4
80 %cmp5 = icmp slt i32 %9, 20
81 br i1 %cmp5, label %do.body1, label %do.end6
83 do.end6: ; preds = %do.cond4
84 %10 = load i32, ptr %i, align 4
85 %inc7 = add nsw i32 %10, 1
86 store i32 %inc7, ptr %i, align 4
89 do.cond8: ; preds = %do.end6
90 %11 = load i32, ptr %i, align 4
91 %cmp9 = icmp slt i32 %11, 10
92 br i1 %cmp9, label %do.body, label %do.end10
94 do.end10: ; preds = %do.cond8
95 %12 = load i32, ptr %val, align 4
96 %13 = load i32, ptr %i, align 4
97 %add11 = add nsw i32 %12, %13
98 %14 = load i32, ptr %j, align 4
99 %add12 = add nsw i32 %add11, %14
100 %15 = load i32, ptr %k, align 4
101 %add13 = add nsw i32 %add12, %15
105 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
106 declare token @llvm.experimental.convergence.entry() #1
108 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
109 declare token @llvm.experimental.convergence.loop() #1
111 ; Function Attrs: convergent noinline norecurse nounwind optnone
112 define internal spir_func void @main() #2 {
114 %0 = call token @llvm.experimental.convergence.entry()
115 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ]
119 ; Function Attrs: convergent norecurse
120 define void @main.1() #3 {
126 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
127 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
128 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
129 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
130 attributes #4 = { convergent }
132 !llvm.module.flags = !{!0, !1, !2}
134 !0 = !{i32 1, !"wchar_size", i32 4}
135 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
136 !2 = !{i32 7, !"frame-pointer", i32 2}