xref: /llvm-project/llvm/test/Transforms/StructurizeCFG/nested-loop-order.ll (revision bf6f82a9df6a1693a5399039dcadd7fc00dab65e)
1cee313d2SEric Christopher; RUN: opt -S -structurizecfg %s -o - | FileCheck %s
2baffd052SArthur Eubanks; RUN: opt -S -passes=structurizecfg %s -o - | FileCheck %s
3cee313d2SEric Christopher
4*bf6f82a9SMatt Arsenaultdefine void @main(ptr addrspace(1) %out) {
5cee313d2SEric Christopher
6cee313d2SEric Christopher; CHECK: main_body:
7cee313d2SEric Christopher; CHECK: br label %LOOP.outer
8cee313d2SEric Christophermain_body:
9cee313d2SEric Christopher  br label %LOOP.outer
10cee313d2SEric Christopher
11cee313d2SEric Christopher; CHECK: LOOP.outer:
12cee313d2SEric Christopher; CHECK: br label %LOOP
13cee313d2SEric ChristopherLOOP.outer:                                       ; preds = %ENDIF28, %main_body
14cee313d2SEric Christopher  %temp8.0.ph = phi float [ 0.000000e+00, %main_body ], [ %tmp35, %ENDIF28 ]
15cee313d2SEric Christopher  %temp4.0.ph = phi i32 [ 0, %main_body ], [ %tmp20, %ENDIF28 ]
16cee313d2SEric Christopher  br label %LOOP
17cee313d2SEric Christopher
18cee313d2SEric Christopher; CHECK: LOOP:
19cee313d2SEric Christopher; br i1 %{{[0-9]+}}, label %ENDIF, label %Flow
20cee313d2SEric ChristopherLOOP:                                             ; preds = %IF29, %LOOP.outer
21cee313d2SEric Christopher  %temp4.0 = phi i32 [ %temp4.0.ph, %LOOP.outer ], [ %tmp20, %IF29 ]
22cee313d2SEric Christopher  %tmp20 = add i32 %temp4.0, 1
23cee313d2SEric Christopher  %tmp22 = icmp sgt i32 %tmp20, 3
24cee313d2SEric Christopher  br i1 %tmp22, label %ENDLOOP, label %ENDIF
25cee313d2SEric Christopher
26cee313d2SEric Christopher; CHECK: Flow3
27cee313d2SEric Christopher; CHECK: br i1 %{{[0-9]+}}, label %ENDLOOP, label %LOOP.outer
28cee313d2SEric Christopher
29cee313d2SEric Christopher; CHECK: ENDLOOP:
30cee313d2SEric Christopher; CHECK: ret void
31cee313d2SEric ChristopherENDLOOP:                                          ; preds = %ENDIF28, %IF29, %LOOP
32cee313d2SEric Christopher  %temp8.1 = phi float [ %temp8.0.ph, %LOOP ], [ %temp8.0.ph, %IF29 ], [ %tmp35, %ENDIF28 ]
33cee313d2SEric Christopher  %tmp23 = icmp eq i32 %tmp20, 3
34cee313d2SEric Christopher  %.45 = select i1 %tmp23, float 0.000000e+00, float 1.000000e+00
35*bf6f82a9SMatt Arsenault  store float %.45, ptr addrspace(1) %out
36cee313d2SEric Christopher  ret void
37cee313d2SEric Christopher
38cee313d2SEric Christopher; CHECK: ENDIF:
39cee313d2SEric Christopher; CHECK: br i1 %tmp31, label %IF29, label %Flow1
40cee313d2SEric ChristopherENDIF:                                            ; preds = %LOOP
41cee313d2SEric Christopher  %tmp31 = icmp sgt i32 %tmp20, 1
42cee313d2SEric Christopher  br i1 %tmp31, label %IF29, label %ENDIF28
43cee313d2SEric Christopher
44cee313d2SEric Christopher; CHECK: Flow:
45cee313d2SEric Christopher; CHECK: br i1 %{{[0-9]+}}, label %Flow2, label %LOOP
46cee313d2SEric Christopher
47cee313d2SEric Christopher; CHECK: IF29:
48cee313d2SEric Christopher; CHECK: br label %Flow1
49cee313d2SEric ChristopherIF29:                                             ; preds = %ENDIF
50cee313d2SEric Christopher  %tmp32 = icmp sgt i32 %tmp20, 2
51cee313d2SEric Christopher  br i1 %tmp32, label %ENDLOOP, label %LOOP
52cee313d2SEric Christopher
53cee313d2SEric Christopher; CHECK: Flow1:
54cee313d2SEric Christopher; CHECK: br label %Flow
55cee313d2SEric Christopher
56cee313d2SEric Christopher; CHECK: Flow2:
57cee313d2SEric Christopher; CHECK: br i1 %{{[0-9]+}}, label %ENDIF28, label %Flow3
58cee313d2SEric Christopher
59cee313d2SEric Christopher; CHECK: ENDIF28:
60cee313d2SEric Christopher; CHECK: br label %Flow3
61cee313d2SEric ChristopherENDIF28:                                          ; preds = %ENDIF
62cee313d2SEric Christopher  %tmp35 = fadd float %temp8.0.ph, 1.0
63cee313d2SEric Christopher  %tmp36 = icmp sgt i32 %tmp20, 2
64cee313d2SEric Christopher  br i1 %tmp36, label %ENDLOOP, label %LOOP.outer
65cee313d2SEric Christopher}
66cee313d2SEric Christopher
674ab3041aSserge-sans-pailleattributes #0 = { "enable-no-nans-fp-math"="true" "unsafe-fp-math"="true" }
68cee313d2SEric Christopherattributes #1 = { nounwind readnone }
69cee313d2SEric Christopherattributes #2 = { readnone }
70