1 ; RUN: opt < %s -S -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
12 define i32 @bar_prof(i32* noalias nocapture readonly %src, i64 %c) !prof !1 {
17 %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
18 %r = phi i32 [ 0, %entry ], [ %add, %loop ]
19 %arrayidx = getelementptr inbounds i32, i32* %src, i64 %iv
20 %src_element = load i32, i32* %arrayidx, align 4
21 %array_const_idx = getelementptr inbounds [9 x i32], [9 x i32]* @known_constant, i64 0, i64 %iv
22 %const_array_element = load i32, i32* %array_const_idx, align 4
23 %mul = mul nsw i32 %src_element, %const_array_element
24 %add = add nsw i32 %mul, %r
25 %inc = add nuw nsw i64 %iv, 1
26 %exitcond86.i = icmp eq i64 %inc, %c
27 br i1 %exitcond86.i, label %loop.end, label %loop, !prof !2
30 %r.lcssa = phi i32 [ %r, %loop ]
34 ; CHECK-LABEL: @bar_prof_flat
35 ; CHECK-NOT: loop.epil
36 define i32 @bar_prof_flat(i32* noalias nocapture readonly %src, i64 %c) !prof !1 {
41 %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
42 %r = phi i32 [ 0, %entry ], [ %add, %loop ]
43 %arrayidx = getelementptr inbounds i32, i32* %src, i64 %iv
44 %src_element = load i32, i32* %arrayidx, align 4
45 %array_const_idx = getelementptr inbounds [9 x i32], [9 x i32]* @known_constant, i64 0, i64 %iv
46 %const_array_element = load i32, i32* %array_const_idx, align 4
47 %mul = mul nsw i32 %src_element, %const_array_element
48 %add = add nsw i32 %mul, %r
49 %inc = add nuw nsw i64 %iv, 1
50 %exitcond86.i = icmp eq i64 %inc, %c
51 br i1 %exitcond86.i, label %loop, label %loop.end, !prof !2
54 %r.lcssa = phi i32 [ %r, %loop ]
58 !1 = !{!"function_entry_count", i64 1}
59 !2 = !{!"branch_weights", i32 1, i32 1000}