blob: 18309b0691fabbc4b875670406333eeda5ebe1be [file] [log] [blame]
Michael Kupersteinb151a642016-11-30 21:13:57 +00001; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll -unroll-allow-peeling 2>&1 | FileCheck %s
2; REQUIRES: asserts
3
4; Make sure we use the profile information correctly to peel-off 3 iterations
5; from the loop, and update the branch weights for the peeled loop properly.
6; CHECK: PEELING loop %for.body with iteration count 3!
7; CHECK-LABEL: @basic
8; CHECK: br i1 %{{.*}}, label %[[NEXT0:.*]], label %for.cond.for.end_crit_edge, !prof !1
9; CHECK: [[NEXT0]]:
10; CHECK: br i1 %{{.*}}, label %[[NEXT1:.*]], label %for.cond.for.end_crit_edge, !prof !2
11; CHECK: [[NEXT1]]:
12; CHECK: br i1 %{{.*}}, label %[[NEXT2:.*]], label %for.cond.for.end_crit_edge, !prof !3
13; CHECK: [[NEXT2]]:
14; CHECK: br i1 %{{.*}}, label %for.body, label %{{.*}}, !prof !4
15
16define void @basic(i32* %p, i32 %k) #0 !prof !0 {
17entry:
18 %cmp3 = icmp slt i32 0, %k
19 br i1 %cmp3, label %for.body.lr.ph, label %for.end
20
21for.body.lr.ph: ; preds = %entry
22 br label %for.body
23
24for.body: ; preds = %for.body.lr.ph, %for.body
25 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
26 %p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
27 %incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1
28 store i32 %i.05, i32* %p.addr.04, align 4
29 %inc = add nsw i32 %i.05, 1
30 %cmp = icmp slt i32 %inc, %k
31 br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !1
32
33for.cond.for.end_crit_edge: ; preds = %for.body
34 br label %for.end
35
36for.end: ; preds = %for.cond.for.end_crit_edge, %entry
37 ret void
38}
39
40!0 = !{!"function_entry_count", i64 1}
41!1 = !{!"branch_weights", i32 3001, i32 1001}
42
43;CHECK: !1 = !{!"branch_weights", i32 900, i32 101}
44;CHECK: !2 = !{!"branch_weights", i32 540, i32 360}
45;CHECK: !3 = !{!"branch_weights", i32 162, i32 378}
Xin Tong29402312017-01-02 20:27:23 +000046;CHECK: !4 = !{!"branch_weights", i32 1399, i32 162}
Michael Kupersteinb151a642016-11-30 21:13:57 +000047