1 ; RUN: opt < %s -lcssa -S -o - | FileCheck %s
2 target triple = "x86_64-unknown-linux-gnu"
5 ; Here LCSSA adds phi-nodes for %x into the loop exits. Then, SSAUpdater needs
6 ; to insert phi-nodes to merge these values. That creates a new def, which in
7 ; its turn needs another LCCSA phi-node, and this test ensures that we insert
11 define internal i32 @foo1() {
17 br i1 undef, label %if, label %loopexit1
20 br i1 undef, label %latch, label %loopexit2
23 br i1 undef, label %header, label %loopexit3
26 ; CHECK: %x.lcssa = phi i32 [ %x, %header ]
28 br label %loop_with_insert_point
31 ; CHECK: %x.lcssa1 = phi i32 [ %x, %if ]
36 ; CHECK: %x.lcssa2 = phi i32 [ %x, %latch ]
38 br label %loop_with_insert_point
40 ; CHECK: loop_with_insert_point:
41 ; CHECK: %x4 = phi i32 [ %x4, %loop_with_insert_point ], [ %x.lcssa2, %loopexit3 ], [ %x.lcssa, %loopexit1 ]
42 loop_with_insert_point:
43 br i1 undef, label %loop_with_insert_point, label %bb
46 ; CHECK: %x4.lcssa = phi i32 [ %x4, %loop_with_insert_point ]
51 ; CHECK: %x3 = phi i32 [ %x4.lcssa, %bb ], [ %x.lcssa1, %loopexit2 ]
57 define internal i32 @foo2() {
63 br i1 undef, label %latch, label %loopexit1
66 br i1 undef, label %header, label %loopexit2
69 ; CHECK: %x.lcssa = phi i32 [ %x, %header ]
71 br label %loop_with_insert_point
74 ; CHECK: %x.lcssa1 = phi i32 [ %x, %latch ]
76 br label %loop_with_insert_point
78 ; CHECK: loop_with_insert_point:
79 ; CHECK: %x2 = phi i32 [ %x2, %loop_with_insert_point ], [ %x.lcssa1, %loopexit2 ], [ %x.lcssa, %loopexit1 ]
80 loop_with_insert_point:
81 br i1 undef, label %loop_with_insert_point, label %exit
84 ; CHECK: %x2.lcssa = phi i32 [ %x2, %loop_with_insert_point ]