blob: cd7969009fbb5b9c0bb8f6ea9747bbbe38d1d00d [file] [log] [blame]
Michael Zolotukhin6bc56d52016-07-20 01:55:27 +00001; RUN: opt < %s -lcssa -S -o - | FileCheck %s
2target triple = "x86_64-unknown-linux-gnu"
3
4; PR28424
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
8; it.
9
10; CHECK-LABEL: @foo1
11define internal i32 @foo1() {
12entry:
13 br label %header
14
15header:
16 %x = add i32 0, 1
17 br i1 undef, label %if, label %loopexit1
18
19if:
20 br i1 undef, label %latch, label %loopexit2
21
22latch:
23 br i1 undef, label %header, label %loopexit3
24
25; CHECK: loopexit1:
26; CHECK: %x.lcssa = phi i32 [ %x, %header ]
27loopexit1:
28 br label %loop_with_insert_point
29
30; CHECK: loopexit2:
31; CHECK: %x.lcssa1 = phi i32 [ %x, %if ]
32loopexit2:
33 br label %exit
34
35; CHECK: loopexit3:
36; CHECK: %x.lcssa2 = phi i32 [ %x, %latch ]
37loopexit3:
38 br label %loop_with_insert_point
39
40; CHECK: loop_with_insert_point:
41; CHECK: %x4 = phi i32 [ %x4, %loop_with_insert_point ], [ %x.lcssa2, %loopexit3 ], [ %x.lcssa, %loopexit1 ]
42loop_with_insert_point:
43 br i1 undef, label %loop_with_insert_point, label %bb
44
45; CHECK: bb:
46; CHECK: %x4.lcssa = phi i32 [ %x4, %loop_with_insert_point ]
47bb:
48 br label %exit
49
50; CHECK: exit:
51; CHECK: %x3 = phi i32 [ %x4.lcssa, %bb ], [ %x.lcssa1, %loopexit2 ]
52exit:
53 ret i32 %x
54}
55
56; CHECK-LABEL: @foo2
57define internal i32 @foo2() {
58entry:
59 br label %header
60
61header:
62 %x = add i32 0, 1
63 br i1 undef, label %latch, label %loopexit1
64
65latch:
66 br i1 undef, label %header, label %loopexit2
67
68; CHECK: loopexit1:
69; CHECK: %x.lcssa = phi i32 [ %x, %header ]
70loopexit1:
71 br label %loop_with_insert_point
72
73; CHECK: loopexit2:
74; CHECK: %x.lcssa1 = phi i32 [ %x, %latch ]
75loopexit2:
76 br label %loop_with_insert_point
77
78; CHECK: loop_with_insert_point:
79; CHECK: %x2 = phi i32 [ %x2, %loop_with_insert_point ], [ %x.lcssa1, %loopexit2 ], [ %x.lcssa, %loopexit1 ]
80loop_with_insert_point:
81 br i1 undef, label %loop_with_insert_point, label %exit
82
83; CHECK: exit:
84; CHECK: %x2.lcssa = phi i32 [ %x2, %loop_with_insert_point ]
85exit:
86 ret i32 %x
87}