1 ; RUN: opt -S -basicaa -licm < %s | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' -S %s| FileCheck %s
4 ; Manually validate LCSSA form is preserved even after SSAUpdater is used to
5 ; promote things in the loop bodies.
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-linux-gnu"
10 @x = common global i32 0, align 4
11 @y = common global i32 0, align 4
13 define void @PR18688() {
14 ; CHECK-LABEL: @PR18688(
17 br i1 undef, label %return, label %outer.preheader
20 br label %outer.header
21 ; CHECK: outer.preheader:
22 ; CHECK: br label %outer.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
31 br label %inner.header
32 ; CHECK: inner.preheader:
33 ; CHECK-NEXT: br label %inner.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
42 store i32 0, i32* @x, align 4
44 ; CHECK: inner.body.rhs:
45 ; CHECK-NEXT: br label %inner.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
52 ; CHECK-NEXT: %[[PHI1:[^,]+]] = phi i32 [ 0, %inner.body.rhs ], [ %[[PHI0]], %inner.header ]
53 ; CHECK-NEXT: br i1 %{{[^,]+}}, label %inner.exit, label %inner.header
58 ; CHECK-NEXT: %[[INNER_LCSSA:[^,]+]] = phi i32 [ %[[PHI1]], %inner.latch ]
59 ; CHECK-NEXT: br label %outer.latch
62 br i1 undef, label %outer.exit, label %outer.header
64 ; CHECK-NEXT: %[[PHI2:[^,]+]] = phi i32 [ %[[INNER_LCSSA]], %inner.exit ], [ 0, %outer.header ]
65 ; CHECK-NEXT: br i1 {{.*}}, label %outer.exit, label %outer.header
70 ; CHECK-NEXT: %[[OUTER_LCSSA:[^,]+]] = phi i32 [ %[[PHI2]], %outer.latch ]
71 ; CHECK-NEXT: store i32 %[[OUTER_LCSSA]]
72 ; CHECK-NEXT: br label %return