Home | History | Annotate | Download | only in LoopUnroll
      1 ; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-threshold=40 -unroll-max-percent-threshold-boost=100 | FileCheck %s
      2 
      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
      4 
      5 ; CHECK-LABEL: @bar_prof
      6 ; CHECK: loop:
      7 ; CHECK: %mul = mul
      8 ; CHECK: %mul.1 = mul
      9 ; CHECK: %mul.2 = mul
     10 ; CHECK: %mul.3 = mul
     11 ; CHECK: loop.epil:
     12 define i32 @bar_prof(i32* noalias nocapture readonly %src, i64 %c) !prof !1 {
     13 entry:
     14   br label %loop
     15 
     16 loop:
     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
     28 
     29 loop.end:
     30   %r.lcssa = phi i32 [ %r, %loop ]
     31   ret i32 %r.lcssa
     32 }
     33 
     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 {
     37 entry:
     38   br label %loop
     39 
     40 loop:
     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
     52 
     53 loop.end:
     54   %r.lcssa = phi i32 [ %r, %loop ]
     55   ret i32 %r.lcssa
     56 }
     57 
     58 !1 = !{!"function_entry_count", i64 1}
     59 !2 = !{!"branch_weights", i32 1, i32 1000}
     60