xref: /llvm-project/llvm/test/CodeGen/SPIRV/structurizer/cf.while.nested.ll (revision 53326ee0cf45fce3f80e2e98638dd27edb20c516)
11ed65febSNathan Gauër; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
21ed65febSNathan Gauër; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
31ed65febSNathan Gauër
41ed65febSNathan Gauër;
51ed65febSNathan Gauër; [numthreads(1, 1, 1)]
61ed65febSNathan Gauër; void main() {
71ed65febSNathan Gauër;   int val=0, i=0, j=0, k=0;
81ed65febSNathan Gauër;
91ed65febSNathan Gauër;   while (i < 10) {
101ed65febSNathan Gauër;     val = val + i;
111ed65febSNathan Gauër;     while (j < 20) {
121ed65febSNathan Gauër;       while (k < 30) {
131ed65febSNathan Gauër;         val = val + k;
141ed65febSNathan Gauër;         ++k;
151ed65febSNathan Gauër;       }
161ed65febSNathan Gauër;
171ed65febSNathan Gauër;       val = val * 2;
181ed65febSNathan Gauër;       ++j;
191ed65febSNathan Gauër;     }
201ed65febSNathan Gauër;
211ed65febSNathan Gauër;     ++i;
221ed65febSNathan Gauër;   }
231ed65febSNathan Gauër; }
241ed65febSNathan Gauër
251ed65febSNathan Gauër; CHECK: %[[#func_12:]] = OpFunction %[[#void:]] DontInline %[[#]]
261ed65febSNathan Gauër; CHECK:    %[[#bb39:]] = OpLabel
271ed65febSNathan Gauër; CHECK:                  OpBranch %[[#bb40:]]
28*53326ee0SNathan Gauër; CHECK:     %[[#bb40]] = OpLabel
291ed65febSNathan Gauër; CHECK:                  OpLoopMerge %[[#bb41:]] %[[#bb42:]] None
30*53326ee0SNathan Gauër; CHECK:                  OpBranchConditional %[[#]] %[[#bb43:]] %[[#bb41]]
31*53326ee0SNathan Gauër; CHECK:     %[[#bb41]] = OpLabel
321ed65febSNathan Gauër; CHECK:                  OpReturn
33*53326ee0SNathan Gauër; CHECK:     %[[#bb43]] = OpLabel
34*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb44:]]
35*53326ee0SNathan Gauër; CHECK:     %[[#bb44]] = OpLabel
36*53326ee0SNathan Gauër; CHECK:                  OpLoopMerge %[[#bb45:]] %[[#bb46:]] None
37*53326ee0SNathan Gauër; CHECK:                  OpBranchConditional %[[#]] %[[#bb47:]] %[[#bb45]]
38*53326ee0SNathan Gauër; CHECK:     %[[#bb45]] = OpLabel
39*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb42]]
40*53326ee0SNathan Gauër; CHECK:     %[[#bb42]] = OpLabel
41*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb40]]
42*53326ee0SNathan Gauër; CHECK:     %[[#bb47]] = OpLabel
43*53326ee0SNathan Gauër; CHECK:                  OpLoopMerge %[[#bb48:]] %[[#bb49:]] None
44*53326ee0SNathan Gauër; CHECK:                  OpBranchConditional %[[#]] %[[#bb49]] %[[#bb48]]
45*53326ee0SNathan Gauër; CHECK:     %[[#bb48]] = OpLabel
46*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb46]]
47*53326ee0SNathan Gauër; CHECK:     %[[#bb46]] = OpLabel
48*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb44]]
49*53326ee0SNathan Gauër; CHECK:     %[[#bb49]] = OpLabel
50*53326ee0SNathan Gauër; CHECK:                  OpBranch %[[#bb47]]
511ed65febSNathan Gauër; CHECK:                  OpFunctionEnd
521ed65febSNathan Gauër; CHECK: %[[#func_37:]] = OpFunction %[[#void:]] None %[[#]]
531ed65febSNathan Gauër; CHECK:    %[[#bb50:]] = OpLabel
541ed65febSNathan Gauër; CHECK:                  OpReturn
551ed65febSNathan Gauër; CHECK:                  OpFunctionEnd
561ed65febSNathan Gauër
571ed65febSNathan Gauër
581ed65febSNathan Gauër
591ed65febSNathan Gauërtarget datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
601ed65febSNathan Gauërtarget triple = "spirv-unknown-vulkan1.3-compute"
611ed65febSNathan Gauër
621ed65febSNathan Gauër; Function Attrs: convergent noinline norecurse nounwind optnone
631ed65febSNathan Gauërdefine internal spir_func void @main() #0 {
641ed65febSNathan Gauërentry:
651ed65febSNathan Gauër  %0 = call token @llvm.experimental.convergence.entry()
661ed65febSNathan Gauër  %val = alloca i32, align 4
671ed65febSNathan Gauër  %i = alloca i32, align 4
681ed65febSNathan Gauër  %j = alloca i32, align 4
691ed65febSNathan Gauër  %k = alloca i32, align 4
701ed65febSNathan Gauër  store i32 0, ptr %val, align 4
711ed65febSNathan Gauër  store i32 0, ptr %i, align 4
721ed65febSNathan Gauër  store i32 0, ptr %j, align 4
731ed65febSNathan Gauër  store i32 0, ptr %k, align 4
741ed65febSNathan Gauër  br label %while.cond
751ed65febSNathan Gauër
761ed65febSNathan Gauërwhile.cond:                                       ; preds = %while.end9, %entry
771ed65febSNathan Gauër  %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
781ed65febSNathan Gauër  %2 = load i32, ptr %i, align 4
791ed65febSNathan Gauër  %cmp = icmp slt i32 %2, 10
801ed65febSNathan Gauër  br i1 %cmp, label %while.body, label %while.end11
811ed65febSNathan Gauër
821ed65febSNathan Gauërwhile.body:                                       ; preds = %while.cond
831ed65febSNathan Gauër  %3 = load i32, ptr %val, align 4
841ed65febSNathan Gauër  %4 = load i32, ptr %i, align 4
851ed65febSNathan Gauër  %add = add nsw i32 %3, %4
861ed65febSNathan Gauër  store i32 %add, ptr %val, align 4
871ed65febSNathan Gauër  br label %while.cond1
881ed65febSNathan Gauër
891ed65febSNathan Gauërwhile.cond1:                                      ; preds = %while.end, %while.body
901ed65febSNathan Gauër  %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
911ed65febSNathan Gauër  %6 = load i32, ptr %j, align 4
921ed65febSNathan Gauër  %cmp2 = icmp slt i32 %6, 20
931ed65febSNathan Gauër  br i1 %cmp2, label %while.body3, label %while.end9
941ed65febSNathan Gauër
951ed65febSNathan Gauërwhile.body3:                                      ; preds = %while.cond1
961ed65febSNathan Gauër  br label %while.cond4
971ed65febSNathan Gauër
981ed65febSNathan Gauërwhile.cond4:                                      ; preds = %while.body6, %while.body3
991ed65febSNathan Gauër  %7 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %5) ]
1001ed65febSNathan Gauër  %8 = load i32, ptr %k, align 4
1011ed65febSNathan Gauër  %cmp5 = icmp slt i32 %8, 30
1021ed65febSNathan Gauër  br i1 %cmp5, label %while.body6, label %while.end
1031ed65febSNathan Gauër
1041ed65febSNathan Gauërwhile.body6:                                      ; preds = %while.cond4
1051ed65febSNathan Gauër  %9 = load i32, ptr %val, align 4
1061ed65febSNathan Gauër  %10 = load i32, ptr %k, align 4
1071ed65febSNathan Gauër  %add7 = add nsw i32 %9, %10
1081ed65febSNathan Gauër  store i32 %add7, ptr %val, align 4
1091ed65febSNathan Gauër  %11 = load i32, ptr %k, align 4
1101ed65febSNathan Gauër  %inc = add nsw i32 %11, 1
1111ed65febSNathan Gauër  store i32 %inc, ptr %k, align 4
1121ed65febSNathan Gauër  br label %while.cond4
1131ed65febSNathan Gauër
1141ed65febSNathan Gauërwhile.end:                                        ; preds = %while.cond4
1151ed65febSNathan Gauër  %12 = load i32, ptr %val, align 4
1161ed65febSNathan Gauër  %mul = mul nsw i32 %12, 2
1171ed65febSNathan Gauër  store i32 %mul, ptr %val, align 4
1181ed65febSNathan Gauër  %13 = load i32, ptr %j, align 4
1191ed65febSNathan Gauër  %inc8 = add nsw i32 %13, 1
1201ed65febSNathan Gauër  store i32 %inc8, ptr %j, align 4
1211ed65febSNathan Gauër  br label %while.cond1
1221ed65febSNathan Gauër
1231ed65febSNathan Gauërwhile.end9:                                       ; preds = %while.cond1
1241ed65febSNathan Gauër  %14 = load i32, ptr %i, align 4
1251ed65febSNathan Gauër  %inc10 = add nsw i32 %14, 1
1261ed65febSNathan Gauër  store i32 %inc10, ptr %i, align 4
1271ed65febSNathan Gauër  br label %while.cond
1281ed65febSNathan Gauër
1291ed65febSNathan Gauërwhile.end11:                                      ; preds = %while.cond
1301ed65febSNathan Gauër  ret void
1311ed65febSNathan Gauër}
1321ed65febSNathan Gauër
1331ed65febSNathan Gauër; Function Attrs: convergent norecurse
1341ed65febSNathan Gauërdefine void @main.1() #1 {
1351ed65febSNathan Gauërentry:
1361ed65febSNathan Gauër  call void @main()
1371ed65febSNathan Gauër  ret void
1381ed65febSNathan Gauër}
1391ed65febSNathan Gauër
1401ed65febSNathan Gauër; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
1411ed65febSNathan Gauërdeclare token @llvm.experimental.convergence.entry() #2
1421ed65febSNathan Gauër
1431ed65febSNathan Gauër; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
1441ed65febSNathan Gauërdeclare token @llvm.experimental.convergence.loop() #2
1451ed65febSNathan Gauër
1461ed65febSNathan Gauërattributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
1471ed65febSNathan Gauërattributes #1 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
1481ed65febSNathan Gauërattributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
1491ed65febSNathan Gauër
1501ed65febSNathan Gauër!llvm.module.flags = !{!0, !1, !2}
1511ed65febSNathan Gauër
1521ed65febSNathan Gauër
1531ed65febSNathan Gauër!0 = !{i32 1, !"wchar_size", i32 4}
1541ed65febSNathan Gauër!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
1551ed65febSNathan Gauër!2 = !{i32 7, !"frame-pointer", i32 2}
1561ed65febSNathan Gauër
1571ed65febSNathan Gauër
158