forked from OSchip/llvm-project
Add test case for LoopSink pass
This test checks that load from constant memory will be sunk regardless of aliasing stores in the loop. Patch by Daniil Suchkov! Differential Revision: https://reviews.llvm.org/D39113 llvm-svn: 316207
This commit is contained in:
parent
6670e42402
commit
1c839629aa
|
@ -280,6 +280,70 @@ define i32 @t5(i32, i32*) #0 !prof !0 {
|
|||
ret i32 10
|
||||
}
|
||||
|
||||
; b1
|
||||
; / \
|
||||
; b2 b6
|
||||
; / \ |
|
||||
; b3 b4 |
|
||||
; \ / |
|
||||
; b5 |
|
||||
; \ /
|
||||
; b7
|
||||
; preheader: 1000
|
||||
; b2: 15
|
||||
; b3: 7
|
||||
; b4: 7
|
||||
; Regardless of aliasing store in loop this load from constant memory can be sunk.
|
||||
; CHECK: t5_const_memory
|
||||
; CHECK: .preheader:
|
||||
; CHECK-NOT: load i32, i32* @g_const
|
||||
; CHECK: .b2:
|
||||
; CHECK: load i32, i32* @g_const
|
||||
; CHECK: br i1 %c2, label %.b3, label %.b4
|
||||
define i32 @t5_const_memory(i32, i32*) #0 !prof !0 {
|
||||
%3 = icmp eq i32 %0, 0
|
||||
br i1 %3, label %.exit, label %.preheader
|
||||
|
||||
.preheader:
|
||||
%invariant = load i32, i32* @g_const
|
||||
br label %.b1
|
||||
|
||||
.b1:
|
||||
%iv = phi i32 [ %t7, %.b7 ], [ 0, %.preheader ]
|
||||
%c1 = icmp sgt i32 %iv, %0
|
||||
br i1 %c1, label %.b2, label %.b6, !prof !1
|
||||
|
||||
.b2:
|
||||
%c2 = icmp sgt i32 %iv, 1
|
||||
br i1 %c2, label %.b3, label %.b4
|
||||
|
||||
.b3:
|
||||
%t3 = sub nsw i32 %invariant, %iv
|
||||
br label %.b5
|
||||
|
||||
.b4:
|
||||
%t4 = add nsw i32 %invariant, %iv
|
||||
br label %.b5
|
||||
|
||||
.b5:
|
||||
%p5 = phi i32 [ %t3, %.b3 ], [ %t4, %.b4 ]
|
||||
%t5 = mul nsw i32 %p5, 5
|
||||
br label %.b7
|
||||
|
||||
.b6:
|
||||
%t6 = call i32 @foo()
|
||||
br label %.b7
|
||||
|
||||
.b7:
|
||||
%p7 = phi i32 [ %t6, %.b6 ], [ %t5, %.b5 ]
|
||||
%t7 = add nuw nsw i32 %iv, 1
|
||||
%c7 = icmp eq i32 %t7, %p7
|
||||
br i1 %c7, label %.b1, label %.exit, !prof !3
|
||||
|
||||
.exit:
|
||||
ret i32 10
|
||||
}
|
||||
|
||||
; b1
|
||||
; / \
|
||||
; b2 b3
|
||||
|
|
Loading…
Reference in New Issue