xref: /llvm-project/llvm/test/Analysis/MemorySSA/multiple-backedges-hal.ll (revision 8e44f13c6d294e6b4864441b22045b507782540c)
1; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
2
3; hfinkel's case
4; [entry]
5;  |
6; .....
7; (clobbering access - b)
8;  |
9; ....  ________________________________
10;  \   /                               |
11;   (x)                                |
12;  ......                              |
13;    |                                 |
14;    |    ______________________       |
15;     \   /                    |       |
16; (starting access)            |       |
17;     ...                      |       |
18; (clobbering access - a)      |       |
19;    ...                       |       |
20;    | |                       |       |
21;    | |_______________________|       |
22;    |                                 |
23;    |_________________________________|
24;
25; More specifically, one access, with multiple clobbering accesses. One of
26; which strictly dominates the access, the other of which has a backedge
27
28; readnone so we don't have a 1:1 mapping of MemorySSA edges to Instructions.
29declare void @doThingWithoutReading() readnone
30declare i8 @getValue() readnone
31declare i1 @getBool() readnone
32
33define hidden void @testcase(ptr %Arg) {
34Entry:
35  call void @doThingWithoutReading()
36  %Val.Entry = call i8 @getValue()
37; CHECK: 1 = MemoryDef(liveOnEntry)
38; CHECK-NEXT: store i8 %Val.Entry
39  store i8 %Val.Entry, ptr %Arg
40  call void @doThingWithoutReading()
41  br label %OuterLoop
42
43OuterLoop:
44; CHECK: 5 = MemoryPhi({Entry,1},{InnerLoop.Tail,3})
45; CHECK-NEXT: %Val.Outer =
46  %Val.Outer = call i8 @getValue()
47; CHECK: 2 = MemoryDef(5)
48; CHECK-NEXT: store i8 %Val.Outer
49  store i8 %Val.Outer, ptr %Arg
50  call void @doThingWithoutReading()
51  br label %InnerLoop
52
53InnerLoop:
54; CHECK: 4 = MemoryPhi({OuterLoop,2},{InnerLoop,3})
55; CHECK-NEXT: ; MemoryUse(4)
56; CHECK-NEXT: %StartingAccess = load
57  %StartingAccess = load i8, ptr %Arg, align 4
58  %Val.Inner = call i8 @getValue()
59; CHECK: 3 = MemoryDef(4)
60; CHECK-NEXT: store i8 %Val.Inner
61  store i8 %Val.Inner, ptr %Arg
62  call void @doThingWithoutReading()
63  %KeepGoing = call i1 @getBool()
64  br i1 %KeepGoing, label %InnerLoop.Tail, label %InnerLoop
65
66InnerLoop.Tail:
67  %KeepGoing.Tail = call i1 @getBool()
68  br i1 %KeepGoing.Tail, label %End, label %OuterLoop
69
70End:
71  ret void
72}
73