2017-02-22 08:27:34 +08:00
|
|
|
; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll 2>&1 | FileCheck %s
|
2017-08-04 07:42:58 +08:00
|
|
|
; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s
|
|
|
|
; Confirm that peeling is disabled if the number of counts required to reach
|
|
|
|
; the hot percentile is above the threshold.
|
|
|
|
; RUN: opt < %s -S -profile-summary-huge-working-set-size-threshold=9 -debug-only=loop-unroll -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s --check-prefix=NOPEEL
|
2016-12-01 05:13:57 +08:00
|
|
|
; REQUIRES: asserts
|
|
|
|
|
|
|
|
; Make sure we use the profile information correctly to peel-off 3 iterations
|
|
|
|
; from the loop, and update the branch weights for the peeled loop properly.
|
2017-01-12 05:42:51 +08:00
|
|
|
|
|
|
|
; CHECK: Loop Unroll: F[basic]
|
2016-12-01 05:13:57 +08:00
|
|
|
; CHECK: PEELING loop %for.body with iteration count 3!
|
2017-01-12 05:42:51 +08:00
|
|
|
; CHECK: Loop Unroll: F[optsize]
|
|
|
|
; CHECK-NOT: PEELING
|
|
|
|
|
2017-08-04 01:52:38 +08:00
|
|
|
; Confirm that no peeling occurs when we are performing full unrolling.
|
2017-08-04 07:42:58 +08:00
|
|
|
; RUN: opt < %s -S -debug-only=loop-unroll -passes='require<opt-remark-emit>,loop(unroll-full)' 2>&1 | FileCheck %s --check-prefix=NOPEEL
|
|
|
|
; NOPEEL-NOT: PEELING
|
2017-08-04 01:52:38 +08:00
|
|
|
|
2016-12-01 05:13:57 +08:00
|
|
|
; CHECK-LABEL: @basic
|
2017-08-04 07:42:58 +08:00
|
|
|
; CHECK: br i1 %{{.*}}, label %[[NEXT0:.*]], label %for.cond.for.end_crit_edge, !prof !15
|
2016-12-01 05:13:57 +08:00
|
|
|
; CHECK: [[NEXT0]]:
|
2017-08-04 07:42:58 +08:00
|
|
|
; CHECK: br i1 %{{.*}}, label %[[NEXT1:.*]], label %for.cond.for.end_crit_edge, !prof !16
|
2016-12-01 05:13:57 +08:00
|
|
|
; CHECK: [[NEXT1]]:
|
2017-08-04 07:42:58 +08:00
|
|
|
; CHECK: br i1 %{{.*}}, label %[[NEXT2:.*]], label %for.cond.for.end_crit_edge, !prof !17
|
2016-12-01 05:13:57 +08:00
|
|
|
; CHECK: [[NEXT2]]:
|
2017-08-04 07:42:58 +08:00
|
|
|
; CHECK: br i1 %{{.*}}, label %for.body, label %{{.*}}, !prof !18
|
2016-12-01 05:13:57 +08:00
|
|
|
|
2017-08-04 07:42:58 +08:00
|
|
|
define void @basic(i32* %p, i32 %k) #0 !prof !15 {
|
2016-12-01 05:13:57 +08:00
|
|
|
entry:
|
|
|
|
%cmp3 = icmp slt i32 0, %k
|
|
|
|
br i1 %cmp3, label %for.body.lr.ph, label %for.end
|
|
|
|
|
|
|
|
for.body.lr.ph: ; preds = %entry
|
|
|
|
br label %for.body
|
|
|
|
|
|
|
|
for.body: ; preds = %for.body.lr.ph, %for.body
|
|
|
|
%i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
|
|
|
|
%p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
|
|
|
|
%incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1
|
|
|
|
store i32 %i.05, i32* %p.addr.04, align 4
|
|
|
|
%inc = add nsw i32 %i.05, 1
|
|
|
|
%cmp = icmp slt i32 %inc, %k
|
2017-08-04 07:42:58 +08:00
|
|
|
br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !16
|
2016-12-01 05:13:57 +08:00
|
|
|
|
|
|
|
for.cond.for.end_crit_edge: ; preds = %for.body
|
|
|
|
br label %for.end
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-01-12 05:42:51 +08:00
|
|
|
; We don't want to peel loops when optimizing for size.
|
|
|
|
; CHECK-LABEL: @optsize
|
|
|
|
; CHECK: for.body.lr.ph:
|
|
|
|
; CHECK-NEXT: br label %for.body
|
|
|
|
; CHECK: for.body:
|
|
|
|
; CHECK-NOT: br
|
|
|
|
; CHECK: br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
|
2017-08-04 07:42:58 +08:00
|
|
|
define void @optsize(i32* %p, i32 %k) #1 !prof !15 {
|
2017-01-12 05:42:51 +08:00
|
|
|
entry:
|
|
|
|
%cmp3 = icmp slt i32 0, %k
|
|
|
|
br i1 %cmp3, label %for.body.lr.ph, label %for.end
|
|
|
|
|
|
|
|
for.body.lr.ph: ; preds = %entry
|
|
|
|
br label %for.body
|
|
|
|
|
|
|
|
for.body: ; preds = %for.body.lr.ph, %for.body
|
|
|
|
%i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
|
|
|
|
%p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
|
|
|
|
%incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1
|
|
|
|
store i32 %i.05, i32* %p.addr.04, align 4
|
|
|
|
%inc = add nsw i32 %i.05, 1
|
|
|
|
%cmp = icmp slt i32 %inc, %k
|
2017-08-04 07:42:58 +08:00
|
|
|
br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !16
|
2017-01-12 05:42:51 +08:00
|
|
|
|
|
|
|
for.cond.for.end_crit_edge: ; preds = %for.body
|
|
|
|
br label %for.end
|
|
|
|
|
|
|
|
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
|
|
|
attributes #1 = { nounwind optsize }
|
|
|
|
|
2017-08-04 07:42:58 +08:00
|
|
|
!llvm.module.flags = !{!1}
|
|
|
|
|
|
|
|
!1 = !{i32 1, !"ProfileSummary", !2}
|
|
|
|
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
|
|
|
|
!3 = !{!"ProfileFormat", !"InstrProf"}
|
|
|
|
!4 = !{!"TotalCount", i64 10}
|
|
|
|
!5 = !{!"MaxCount", i64 3}
|
|
|
|
!6 = !{!"MaxInternalCount", i64 1}
|
|
|
|
!7 = !{!"MaxFunctionCount", i64 3}
|
|
|
|
!8 = !{!"NumCounts", i64 2}
|
|
|
|
!9 = !{!"NumFunctions", i64 2}
|
|
|
|
!10 = !{!"DetailedSummary", !11}
|
|
|
|
!11 = !{!12, !13, !14}
|
|
|
|
!12 = !{i32 10000, i64 3, i32 2}
|
|
|
|
!13 = !{i32 999000, i64 1, i32 10}
|
|
|
|
!14 = !{i32 999999, i64 1, i32 10}
|
|
|
|
!15 = !{!"function_entry_count", i64 1}
|
|
|
|
!16 = !{!"branch_weights", i32 3001, i32 1001}
|
|
|
|
|
|
|
|
;CHECK: !15 = !{!"branch_weights", i32 900, i32 101}
|
|
|
|
;CHECK: !16 = !{!"branch_weights", i32 540, i32 360}
|
|
|
|
;CHECK: !17 = !{!"branch_weights", i32 162, i32 378}
|
|
|
|
;CHECK: !18 = !{!"branch_weights", i32 1399, i32 162}
|
2016-12-01 05:13:57 +08:00
|
|
|
|