• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -S -loop-unroll -unroll-runtime=true -unroll-count=4 | FileCheck %s
2; RUN: opt < %s -S -passes=loop-unroll -unroll-runtime=true -unroll-count=4 | FileCheck %s
3
4;; Check that the remainder loop is properly assigned a branch weight for its latch branch.
5; CHECK-LABEL: @test(
6; CHECK-LABEL: for.body:
7; CHECK: br i1 [[COND1:%.*]], label %for.end.loopexit.unr-lcssa.loopexit, label %for.body, !prof ![[#PROF:]], !llvm.loop ![[#LOOP:]]
8; CHECK-LABEL: for.body.epil:
9; CHECK: br i1 [[COND2:%.*]], label  %for.body.epil, label %for.end.loopexit.epilog-lcssa, !prof ![[#PROF2:]], !llvm.loop ![[#LOOP2:]]
10; CHECK: ![[#PROF]] = !{!"branch_weights", i32 1, i32 9999}
11; CHECK: ![[#PROF2]] = !{!"branch_weights", i32 3, i32 1}
12
13define i3 @test(i3* %a, i3 %n) {
14entry:
15  %cmp1 = icmp eq i3 %n, 0
16  br i1 %cmp1, label %for.end, label %for.body
17
18for.body:
19  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
20  %sum.02 = phi i3 [ %add, %for.body ], [ 0, %entry ]
21  %arrayidx = getelementptr inbounds i3, i3* %a, i64 %indvars.iv
22  %0 = load i3, i3* %arrayidx
23  %add = add nsw i3 %0, %sum.02
24  %indvars.iv.next = add i64 %indvars.iv, 1
25  %lftr.wideiv = trunc i64 %indvars.iv.next to i3
26  %exitcond = icmp eq i3 %lftr.wideiv, %n
27  br i1 %exitcond, label %for.end, label %for.body, !prof !0
28
29for.end:
30  %sum.0.lcssa = phi i3 [ 0, %entry ], [ %add, %for.body ]
31  ret i3 %sum.0.lcssa
32}
33
34!0 = !{!"branch_weights", i32 1, i32 9999}
35