blob: c2216a47bb204951554989686e3bb2b7b6d3fe5f [file] [log] [blame]
Chad Rosier232e29e2016-07-06 21:20:47 +00001; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s
Geoff Berryb96d3b22016-06-01 21:30:40 +00002; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
George Burgess IVe1100f52016-02-02 22:46:49 +00003;
4; many-dom.ll, with an added back-edge back into the switch.
5; Because people love their gotos.
6
7declare i1 @getBool() readnone
8
9define i32 @foo(i32* %p) {
10entry:
11 br label %loopbegin
12
13loopbegin:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000014; CHECK: 8 = MemoryPhi({entry,liveOnEntry},{sw.epilog,6})
George Burgess IVe1100f52016-02-02 22:46:49 +000015; CHECK-NEXT: %n =
16 %n = phi i32 [ 0, %entry ], [ %1, %sw.epilog ]
17 %m = alloca i32, align 4
18 switch i32 %n, label %sw.default [
19 i32 0, label %sw.bb
20 i32 1, label %sw.bb1
21 i32 2, label %sw.bb2
22 i32 3, label %sw.bb3
23 ]
24
25sw.bb:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000026; CHECK: 1 = MemoryDef(8)
George Burgess IVe1100f52016-02-02 22:46:49 +000027; CHECK-NEXT: store i32 1
28 store i32 1, i32* %m, align 4
29 br label %sw.epilog
30
31sw.bb1:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000032; CHECK: 2 = MemoryDef(8)
George Burgess IVe1100f52016-02-02 22:46:49 +000033; CHECK-NEXT: store i32 2
34 store i32 2, i32* %m, align 4
35 br label %sw.epilog
36
37sw.bb2:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000038; CHECK: 3 = MemoryDef(8)
George Burgess IVe1100f52016-02-02 22:46:49 +000039; CHECK-NEXT: store i32 3
40 store i32 3, i32* %m, align 4
41 br label %sw.epilog
42
43sw.bb3:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000044; CHECK: 9 = MemoryPhi({loopbegin,8},{sw.almostexit,6})
45; CHECK: 4 = MemoryDef(9)
George Burgess IVe1100f52016-02-02 22:46:49 +000046; CHECK-NEXT: store i32 4
47 store i32 4, i32* %m, align 4
48 br label %sw.epilog
49
50sw.default:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000051; CHECK: 5 = MemoryDef(8)
George Burgess IVe1100f52016-02-02 22:46:49 +000052; CHECK-NEXT: store i32 5
53 store i32 5, i32* %m, align 4
54 br label %sw.epilog
55
56sw.epilog:
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000057; CHECK: 10 = MemoryPhi({sw.default,5},{sw.bb3,4},{sw.bb,1},{sw.bb1,2},{sw.bb2,3})
58; CHECK-NEXT: MemoryUse(10)
George Burgess IVe1100f52016-02-02 22:46:49 +000059; CHECK-NEXT: %0 =
60 %0 = load i32, i32* %m, align 4
Mandeep Singh Grang73f00952016-11-21 19:33:02 +000061; CHECK: 6 = MemoryDef(10)
George Burgess IVe1100f52016-02-02 22:46:49 +000062; CHECK-NEXT: %1 =
63 %1 = load volatile i32, i32* %p, align 4
64 %2 = icmp eq i32 %0, %1
65 br i1 %2, label %sw.almostexit, label %loopbegin
66
67sw.almostexit:
68 %3 = icmp eq i32 0, %1
69 br i1 %3, label %exit, label %sw.bb3
70
71exit:
72; CHECK: 7 = MemoryDef(6)
73; CHECK-NEXT: %4 = load volatile i32
74 %4 = load volatile i32, i32* %p, align 4
75 %5 = add i32 %4, %1
76 ret i32 %5
77}