1 ; RUN: opt < %s -S -passes=loop-unroll -unroll-runtime -unroll-threshold=40 -unroll-max-percent-threshold-boost=100 | FileCheck %s
3 @known_constant = internal unnamed_addr constant [9 x i32] [i32 0, i32 -1, i32 0, i32 -1, i32 5, i32 -1, i32 0, i32 -1, i32 0], align 16
5 ; CHECK-LABEL: @bar_prof
11 ; CHECK: br i1 %niter.ncmp.7, label %loop.end.unr-lcssa.loopexit, label %loop, !prof [[PROF0:![0-9]+]]
13 ; CHECK: br i1 %epil.iter.cmp, label %loop.epil, label %loop.end.epilog-lcssa, !prof [[PROF1:![0-9]+]], !llvm.loop {{![0-9]+}}
14 define i32 @bar_prof(ptr noalias nocapture readonly %src, i64 %c) !prof !1 {
19 %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
20 %r = phi i32 [ 0, %entry ], [ %add, %loop ]
21 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %iv
22 %src_element = load i32, ptr %arrayidx, align 4
23 %array_const_idx = getelementptr inbounds [9 x i32], ptr @known_constant, i64 0, i64 %iv
24 %const_array_element = load i32, ptr %array_const_idx, align 4
25 %mul = mul nsw i32 %src_element, %const_array_element
26 %add = add nsw i32 %mul, %r
27 %inc = add nuw nsw i64 %iv, 1
28 %exitcond86.i = icmp eq i64 %inc, %c
29 br i1 %exitcond86.i, label %loop.end, label %loop, !prof !2
32 %r.lcssa = phi i32 [ %r, %loop ]
36 ; CHECK-LABEL: @bar_prof_flat
37 ; CHECK-NOT: loop.epil
38 define i32 @bar_prof_flat(ptr noalias nocapture readonly %src, i64 %c) !prof !1 {
43 %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
44 %r = phi i32 [ 0, %entry ], [ %add, %loop ]
45 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %iv
46 %src_element = load i32, ptr %arrayidx, align 4
47 %array_const_idx = getelementptr inbounds [9 x i32], ptr @known_constant, i64 0, i64 %iv
48 %const_array_element = load i32, ptr %array_const_idx, align 4
49 %mul = mul nsw i32 %src_element, %const_array_element
50 %add = add nsw i32 %mul, %r
51 %inc = add nuw nsw i64 %iv, 1
52 %exitcond86.i = icmp eq i64 %inc, %c
53 br i1 %exitcond86.i, label %loop, label %loop.end, !prof !2
56 %r.lcssa = phi i32 [ %r, %loop ]
60 !1 = !{!"function_entry_count", i64 1}
61 !2 = !{!"branch_weights", i32 1, i32 1000}
63 ; CHECK: [[PROF0]] = !{!"branch_weights", i32 1, i32 124}
64 ; CHECK: [[PROF1]] = !{!"branch_weights", i32 3, i32 1}