1 ; RUN: opt -disable-output -aa-pipeline=basic-aa -passes='loop-mssa(licm),print<memoryssa>' < %s 2>&1 | FileCheck %s
4 @a = external dso_local global i16, align 1
5 @c = external dso_local global i16, align 1
10 ; CHECK-NEXT: %res.addr.i = alloca i16
11 ; CHECK-NEXT: ; MemoryUse(liveOnEntry)
12 ; CHECK-NEXT: %c.promoted = load i16, ptr @c
13 ; CHECK-NEXT: br label %for.cond.i
16 ; CHECK-NEXT: ; [[NO5:.*]] = MemoryPhi({entry,liveOnEntry},{f.exit.i,[[NO5]]})
17 ; CHECK-NEXT: %inc.i1 = phi i16 [ %inc.i, %f.exit.i ], [ %c.promoted, %entry ]
18 ; CHECK-NEXT: %inc.i = add nsw i16 %inc.i1, 1
19 ; CHECK-NEXT: br i1 false, label %f.exit.thread.i, label %f.exit.i
21 ; CHECK: f.exit.thread.i:
22 ; CHECK-NEXT: %inc.i.lcssa = phi i16 [ %inc.i, %for.cond.i ]
23 ; CHECK-NEXT: ; [[NO6:.*]] = MemoryDef([[NO5]])
24 ; CHECK-NEXT: store i16 %inc.i.lcssa, ptr @c, align 1
25 ; CHECK-NEXT: ; [[NO2:.*]] = MemoryDef([[NO6]])
26 ; CHECK-NEXT: store i16 1, ptr @a, align 1
27 ; CHECK-NEXT: ; MemoryUse([[NO6]])
28 ; CHECK-NEXT: %tmp2 = load i16, ptr @c, align 1
29 ; CHECK-NEXT: br label %g.exit
32 ; CHECK-NEXT: br i1 false, label %g.exit.loopexit, label %for.cond.i
34 ; CHECK: g.exit.loopexit:
35 ; CHECK-NEXT: %inc.i.lcssa2 = phi i16 [ %inc.i, %f.exit.i ]
36 ; CHECK-NEXT: ; [[NO7:.*]] = MemoryDef([[NO5]])
37 ; CHECK-NEXT: store i16 %inc.i.lcssa2, ptr @c, align 1
38 ; CHECK-NEXT: br label %g.exit
41 ; CHECK-NEXT: ; [[NO4:.*]] = MemoryPhi({f.exit.thread.i,[[NO2]]},{g.exit.loopexit,[[NO7]]})
42 ; CHECK-NEXT: ; MemoryUse([[NO4]])
43 ; CHECK-NEXT: %tmp1 = load i16, ptr @c, align 1
44 ; CHECK-NEXT: ; [[NO3:.*]] = MemoryDef([[NO4]])
45 ; CHECK-NEXT: store i16 %tmp1, ptr %res.addr.i, align 1
46 ; CHECK-NEXT: ret void
48 define dso_local void @main() {
50 %res.addr.i = alloca i16, align 1
53 for.cond.i: ; preds = %f.exit.i, %entry
54 %tmp0 = load i16, ptr @c, align 1
55 %inc.i = add nsw i16 %tmp0, 1
56 store i16 %inc.i, ptr @c, align 1
57 br i1 false, label %f.exit.thread.i, label %f.exit.i
59 f.exit.thread.i: ; preds = %for.cond.i
60 store i16 1, ptr @a, align 1
61 %tmp2 = load i16, ptr @c, align 1
64 f.exit.i: ; preds = %for.cond.i
65 br i1 false, label %g.exit, label %for.cond.i
67 g.exit: ; preds = %f.exit.i, %f.exit.thread.i
68 %tmp1 = load i16, ptr @c, align 1
69 store i16 %tmp1, ptr %res.addr.i, align 1