forked from OSchip/llvm-project
[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 llvm-svn: 292730
This commit is contained in:
parent
b81980a376
commit
bff575fe29
|
@ -9,7 +9,7 @@
|
|||
define i32 @foo(i32* %a) {
|
||||
; CHECK: 1 = MemoryDef(liveOnEntry)
|
||||
; CHECK-NEXT: store i32 0
|
||||
store i32 0, i32* %a, align 4, !llvm.invariant.group !0
|
||||
store i32 0, i32* %a, align 4, !invariant.group !0
|
||||
|
||||
; CHECK: 2 = MemoryDef(1)
|
||||
; CHECK-NEXT: store i32 1
|
||||
|
@ -19,12 +19,85 @@ define i32 @foo(i32* %a) {
|
|||
%a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
|
||||
%a32 = bitcast i8* %a8 to i32*
|
||||
|
||||
; This have to be MemoryUse(1), because we can't skip the barrier based on
|
||||
; invariant.group.
|
||||
; CHECK: MemoryUse(2)
|
||||
; CHECK-NEXT: %2 = load i32
|
||||
%2 = load i32, i32* %a32, align 4, !llvm.invariant.group !0
|
||||
%2 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
ret i32 %2
|
||||
}
|
||||
|
||||
define i32 @skipBarrier(i32* %a) {
|
||||
; CHECK: 1 = MemoryDef(liveOnEntry)
|
||||
; CHECK-NEXT: store i32 0
|
||||
store i32 0, i32* %a, align 4, !invariant.group !0
|
||||
|
||||
%1 = bitcast i32* %a to i8*
|
||||
%a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
|
||||
%a32 = bitcast i8* %a8 to i32*
|
||||
|
||||
; We can skip the barrier only if the "skip" is not based on !invariant.group.
|
||||
; CHECK: MemoryUse(1)
|
||||
; CHECK-NEXT: %2 = load i32
|
||||
%2 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
ret i32 %2
|
||||
}
|
||||
|
||||
define i32 @skipBarrier2(i32* %a) {
|
||||
|
||||
; CHECK: MemoryUse(liveOnEntry)
|
||||
; CHECK-NEXT: %v = load i32
|
||||
%v = load i32, i32* %a, align 4, !invariant.group !0
|
||||
|
||||
%1 = bitcast i32* %a to i8*
|
||||
%a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
|
||||
%a32 = bitcast i8* %a8 to i32*
|
||||
|
||||
; We can skip the barrier only if the "skip" is not based on !invariant.group.
|
||||
; CHECK: MemoryUse(liveOnEntry)
|
||||
; CHECK-NEXT: %v2 = load i32
|
||||
%v2 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
; CHECK: 1 = MemoryDef(liveOnEntry)
|
||||
; CHECK-NEXT: store i32 1
|
||||
store i32 1, i32* @g, align 4
|
||||
|
||||
; FIXME: based on invariant.group it should be MemoryUse(liveOnEntry)
|
||||
; CHECK: MemoryUse(1)
|
||||
; CHECK-NEXT: %v3 = load i32
|
||||
%v3 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
%add = add nsw i32 %v2, %v3
|
||||
%add2 = add nsw i32 %add, %v
|
||||
ret i32 %add2
|
||||
}
|
||||
|
||||
define i32 @handleInvariantGroups(i32* %a) {
|
||||
; CHECK: 1 = MemoryDef(liveOnEntry)
|
||||
; CHECK-NEXT: store i32 0
|
||||
store i32 0, i32* %a, align 4, !invariant.group !0
|
||||
|
||||
; CHECK: 2 = MemoryDef(1)
|
||||
; CHECK-NEXT: store i32 1
|
||||
store i32 1, i32* @g, align 4
|
||||
%1 = bitcast i32* %a to i8*
|
||||
%a8 = call i8* @llvm.invariant.group.barrier(i8* %1)
|
||||
%a32 = bitcast i8* %a8 to i32*
|
||||
|
||||
; CHECK: MemoryUse(2)
|
||||
; CHECK-NEXT: %2 = load i32
|
||||
%2 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
|
||||
; CHECK: 3 = MemoryDef(2)
|
||||
; CHECK-NEXT: store i32 2
|
||||
store i32 2, i32* @g, align 4
|
||||
|
||||
; FIXME: This can be changed to MemoryUse(2)
|
||||
; CHECK: MemoryUse(3)
|
||||
; CHECK-NEXT: %3 = load i32
|
||||
%3 = load i32, i32* %a32, align 4, !invariant.group !0
|
||||
%add = add nsw i32 %2, %3
|
||||
ret i32 %add
|
||||
}
|
||||
|
||||
declare i8* @llvm.invariant.group.barrier(i8*)
|
||||
|
||||
!0 = !{!"group1"}
|
||||
|
|
Loading…
Reference in New Issue