llvm.org GIT mirror llvm / 1fbffa1
[MemorySSA] Fix invariant.group test and add new Summary: This test had a bug: !llvm.invariant.group instead of !invariant.group. Also add some new test for future development. All tests passes, when MSSA will support invariant.group only the lines with FIXIT should be changed. Reviewers: dberlin, george.burgess.iv Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28969 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292730 91177308-0d34-0410-b5e6-96231b3b80d8 Piotr Padlewski 2 years ago
1 changed file(s) with 75 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
88 define i32 @foo(i32* %a) {
99 ; CHECK: 1 = MemoryDef(liveOnEntry)
1010 ; CHECK-NEXT: store i32 0
11 store i32 0, i32* %a, align 4, !llvm.invariant.group !0
11 store i32 0, i32* %a, align 4, !invariant.group !0
1212
1313 ; CHECK: 2 = MemoryDef(1)
1414 ; CHECK-NEXT: store i32 1
1818 %a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
1919 %a32 = bitcast i8* %a8 to i32*
2020
21 ; This have to be MemoryUse(1), because we can't skip the barrier based on
22 ; invariant.group.
2123 ; CHECK: MemoryUse(2)
2224 ; CHECK-NEXT: %2 = load i32
23 %2 = load i32, i32* %a32, align 4, !llvm.invariant.group !0
25 %2 = load i32, i32* %a32, align 4, !invariant.group !0
2426 ret i32 %2
27 }
28
29 define i32 @skipBarrier(i32* %a) {
30 ; CHECK: 1 = MemoryDef(liveOnEntry)
31 ; CHECK-NEXT: store i32 0
32 store i32 0, i32* %a, align 4, !invariant.group !0
33
34 %1 = bitcast i32* %a to i8*
35 %a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
36 %a32 = bitcast i8* %a8 to i32*
37
38 ; We can skip the barrier only if the "skip" is not based on !invariant.group.
39 ; CHECK: MemoryUse(1)
40 ; CHECK-NEXT: %2 = load i32
41 %2 = load i32, i32* %a32, align 4, !invariant.group !0
42 ret i32 %2
43 }
44
45 define i32 @skipBarrier2(i32* %a) {
46
47 ; CHECK: MemoryUse(liveOnEntry)
48 ; CHECK-NEXT: %v = load i32
49 %v = load i32, i32* %a, align 4, !invariant.group !0
50
51 %1 = bitcast i32* %a to i8*
52 %a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
53 %a32 = bitcast i8* %a8 to i32*
54
55 ; We can skip the barrier only if the "skip" is not based on !invariant.group.
56 ; CHECK: MemoryUse(liveOnEntry)
57 ; CHECK-NEXT: %v2 = load i32
58 %v2 = load i32, i32* %a32, align 4, !invariant.group !0
59 ; CHECK: 1 = MemoryDef(liveOnEntry)
60 ; CHECK-NEXT: store i32 1
61 store i32 1, i32* @g, align 4
62
63 ; FIXME: based on invariant.group it should be MemoryUse(liveOnEntry)
64 ; CHECK: MemoryUse(1)
65 ; CHECK-NEXT: %v3 = load i32
66 %v3 = load i32, i32* %a32, align 4, !invariant.group !0
67 %add = add nsw i32 %v2, %v3
68 %add2 = add nsw i32 %add, %v
69 ret i32 %add2
70 }
71
72 define i32 @handleInvariantGroups(i32* %a) {
73 ; CHECK: 1 = MemoryDef(liveOnEntry)
74 ; CHECK-NEXT: store i32 0
75 store i32 0, i32* %a, align 4, !invariant.group !0
76
77 ; CHECK: 2 = MemoryDef(1)
78 ; CHECK-NEXT: store i32 1
79 store i32 1, i32* @g, align 4
80 %1 = bitcast i32* %a to i8*
81 %a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
82 %a32 = bitcast i8* %a8 to i32*
83
84 ; CHECK: MemoryUse(2)
85 ; CHECK-NEXT: %2 = load i32
86 %2 = load i32, i32* %a32, align 4, !invariant.group !0
87
88 ; CHECK: 3 = MemoryDef(2)
89 ; CHECK-NEXT: store i32 2
90 store i32 2, i32* @g, align 4
91
92 ; FIXME: This can be changed to MemoryUse(2)
93 ; CHECK: MemoryUse(3)
94 ; CHECK-NEXT: %3 = load i32
95 %3 = load i32, i32* %a32, align 4, !invariant.group !0
96 %add = add nsw i32 %2, %3
97 ret i32 %add
2598 }
2699
27100 declare i8* @llvm.invariant.group.barrier(i8*)