1; RUN: opt -S -basicaa -licm < %s | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' -S %s| FileCheck %s
3;
4; Manually validate LCSSA form is preserved even after SSAUpdater is used to
5; promote things in the loop bodies.
6
7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-unknown-linux-gnu"
9
10@x = common global i32 0, align 4
11@y = common global i32 0, align 4
12
13define void @PR18688() {
14; CHECK-LABEL: @PR18688(
15
16entry:
17  br i1 undef, label %return, label %outer.preheader
18
19outer.preheader:
20  br label %outer.header
21; CHECK: outer.preheader:
22; CHECK: br label %outer.header
23
24outer.header:
25  store i32 0, i32* @x, align 4
26  br i1 undef, label %outer.latch, label %inner.preheader
27; CHECK: outer.header:
28; CHECK-NEXT: br i1 undef, label %outer.latch, label %inner.preheader
29
30inner.preheader:
31  br label %inner.header
32; CHECK: inner.preheader:
33; CHECK-NEXT: br label %inner.header
34
35inner.header:
36  br i1 undef, label %inner.body.rhs, label %inner.latch
37; CHECK: inner.header:
38; CHECK-NEXT: %[[PHI0:[^,]+]] = phi i32 [ %{{[^,]+}}, %inner.latch ], [ 0, %inner.preheader ]
39; CHECK-NEXT: br i1 undef, label %inner.body.rhs, label %inner.latch
40
41inner.body.rhs:
42  store i32 0, i32* @x, align 4
43  br label %inner.latch
44; CHECK: inner.body.rhs:
45; CHECK-NEXT: br label %inner.latch
46
47inner.latch:
48  %y_val = load i32, i32* @y, align 4
49  %icmp = icmp eq i32 %y_val, 0
50  br i1 %icmp, label %inner.exit, label %inner.header
51; CHECK: inner.latch:
52; CHECK-NEXT: %[[PHI1:[^,]+]] = phi i32 [ 0, %inner.body.rhs ], [ %[[PHI0]], %inner.header ]
53; CHECK-NEXT: br i1 %{{[^,]+}}, label %inner.exit, label %inner.header
54
55inner.exit:
56  br label %outer.latch
57; CHECK: inner.exit:
58; CHECK-NEXT: %[[INNER_LCSSA:[^,]+]] = phi i32 [ %[[PHI1]], %inner.latch ]
59; CHECK-NEXT: br label %outer.latch
60
61outer.latch:
62  br i1 undef, label %outer.exit, label %outer.header
63; CHECK: outer.latch:
64; CHECK-NEXT: %[[PHI2:[^,]+]] = phi i32 [ %[[INNER_LCSSA]], %inner.exit ], [ 0, %outer.header ]
65; CHECK-NEXT: br i1 {{.*}}, label %outer.exit, label %outer.header
66
67outer.exit:
68  br label %return
69; CHECK: outer.exit:
70; CHECK-NEXT: %[[OUTER_LCSSA:[^,]+]] = phi i32 [ %[[PHI2]], %outer.latch ]
71; CHECK-NEXT: store i32 %[[OUTER_LCSSA]]
72; CHECK-NEXT: br label %return
73
74return:
75  ret void
76}
77
78