1 ; RUN: opt -disable-output -loop-simplify -lcssa -licm -print-memoryssa < %s -enable-new-pm=0 2>&1 | FileCheck %s
2 ; RUN: opt -disable-output -aa-pipeline=basic-aa -passes='loop-mssa(licm),print<memoryssa>' < %s 2>&1 | FileCheck %s
5 @a = external dso_local global i16, align 1
6 @c = external dso_local global i16, align 1
11 ; CHECK-NEXT: %res.addr.i = alloca i16
12 ; CHECK-NEXT: ; MemoryUse(liveOnEntry)
13 ; CHECK-NEXT: %c.promoted = load i16, i16* @c
14 ; CHECK-NEXT: br label %for.cond.i
17 ; CHECK-NEXT: ; [[NO5:.*]] = MemoryPhi({entry,liveOnEntry},{f.exit.i,[[NO5]]})
18 ; CHECK-NEXT: %inc.i1 = phi i16 [ %inc.i, %f.exit.i ], [ %c.promoted, %entry ]
19 ; CHECK-NEXT: %inc.i = add nsw i16 %inc.i1, 1
20 ; CHECK-NEXT: br i1 false, label %f.exit.thread.i, label %f.exit.i
22 ; CHECK: f.exit.thread.i:
23 ; CHECK-NEXT: %inc.i.lcssa = phi i16 [ %inc.i, %for.cond.i ]
24 ; CHECK-NEXT: ; [[NO6:.*]] = MemoryDef([[NO5]])
25 ; CHECK-NEXT: store i16 %inc.i.lcssa, i16* @c, align 1
26 ; CHECK-NEXT: ; [[NO2:.*]] = MemoryDef([[NO6]])
27 ; CHECK-NEXT: store i16 1, i16* @a, align 1
28 ; CHECK-NEXT: ; MemoryUse([[NO2]])
29 ; CHECK-NEXT: %tmp2 = load i16, i16* @c, align 1
30 ; CHECK-NEXT: br label %g.exit
33 ; CHECK-NEXT: br i1 false, label %g.exit.loopexit, label %for.cond.i
35 ; CHECK: g.exit.loopexit:
36 ; CHECK-NEXT: %inc.i.lcssa2 = phi i16 [ %inc.i, %f.exit.i ]
37 ; CHECK-NEXT: ; [[NO7:.*]] = MemoryDef([[NO5]])
38 ; CHECK-NEXT: store i16 %inc.i.lcssa2, i16* @c, align 1
39 ; CHECK-NEXT: br label %g.exit
42 ; CHECK-NEXT: ; [[NO4:.*]] = MemoryPhi({f.exit.thread.i,[[NO2]]},{g.exit.loopexit,[[NO7]]})
43 ; CHECK-NEXT: ; MemoryUse([[NO4]])
44 ; CHECK-NEXT: %tmp1 = load i16, i16* @c, align 1
45 ; CHECK-NEXT: ; [[NO3:.*]] = MemoryDef([[NO4]])
46 ; CHECK-NEXT: store i16 %tmp1, i16* %res.addr.i, align 1
47 ; CHECK-NEXT: ret void
49 define dso_local void @main() {
51 %res.addr.i = alloca i16, align 1
54 for.cond.i: ; preds = %f.exit.i, %entry
55 %tmp0 = load i16, i16* @c, align 1
56 %inc.i = add nsw i16 %tmp0, 1
57 store i16 %inc.i, i16* @c, align 1
58 br i1 false, label %f.exit.thread.i, label %f.exit.i
60 f.exit.thread.i: ; preds = %for.cond.i
61 store i16 1, i16* @a, align 1
62 %tmp2 = load i16, i16* @c, align 1
65 f.exit.i: ; preds = %for.cond.i
66 br i1 false, label %g.exit, label %for.cond.i
68 g.exit: ; preds = %f.exit.i, %f.exit.thread.i
69 %tmp1 = load i16, i16* @c, align 1
70 store i16 %tmp1, i16* %res.addr.i, align 1