1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes='print<scalar-evolution>,loop-unroll' -unroll-runtime < %s 2>/dev/null | FileCheck %s
4 define i32 @f(i1 %cond1) #0 !prof !0 {
5 ; CHECK-LABEL: define i32 @f
6 ; CHECK-SAME: (i1 [[COND1:%.*]]) !prof [[PROF0:![0-9]+]] {
8 ; CHECK-NEXT: br label [[LOOP1_PEEL_BEGIN:%.*]]
9 ; CHECK: loop1.peel.begin:
10 ; CHECK-NEXT: br label [[LOOP1_PEEL:%.*]]
12 ; CHECK-NEXT: [[LD_PEEL:%.*]] = load i64, ptr null, align 8
13 ; CHECK-NEXT: br i1 [[COND1]], label [[LOOP1_PEEL_NEXT:%.*]], label [[EXIT1:%.*]], !prof [[PROF1:![0-9]+]]
14 ; CHECK: loop1.peel.next:
15 ; CHECK-NEXT: br label [[LOOP1_PEEL_NEXT1:%.*]]
16 ; CHECK: loop1.peel.next1:
17 ; CHECK-NEXT: br label [[ENTRY_PEEL_NEWPH:%.*]]
18 ; CHECK: entry.peel.newph:
19 ; CHECK-NEXT: br label [[LOOP1:%.*]]
21 ; CHECK-NEXT: [[LD:%.*]] = load i64, ptr null, align 8
22 ; CHECK-NEXT: br i1 [[COND1]], label [[LOOP1]], label [[EXIT1_LOOPEXIT:%.*]], !prof [[PROF2:![0-9]+]], !llvm.loop [[LOOP3:![0-9]+]]
23 ; CHECK: exit1.loopexit:
24 ; CHECK-NEXT: [[LD_LCSSA_PH:%.*]] = phi i64 [ [[LD]], [[LOOP1]] ]
25 ; CHECK-NEXT: br label [[EXIT1]]
27 ; CHECK-NEXT: [[LD_LCSSA:%.*]] = phi i64 [ [[LD_PEEL]], [[LOOP1_PEEL]] ], [ [[LD_LCSSA_PH]], [[EXIT1_LOOPEXIT]] ]
28 ; CHECK-NEXT: br label [[ENTRY2:%.*]]
30 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[LD_LCSSA]], 1
31 ; CHECK-NEXT: [[XTRAITER:%.*]] = and i64 [[TMP0]], 7
32 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i64 [[LD_LCSSA]], 7
33 ; CHECK-NEXT: br i1 [[TMP1]], label [[EXIT2_UNR_LCSSA:%.*]], label [[ENTRY2_NEW:%.*]]
35 ; CHECK-NEXT: [[UNROLL_ITER:%.*]] = sub i64 [[TMP0]], [[XTRAITER]]
36 ; CHECK-NEXT: br label [[LOOP2:%.*]]
38 ; CHECK-NEXT: [[PHI:%.*]] = phi i64 [ 0, [[ENTRY2_NEW]] ], [ [[INC_7:%.*]], [[LOOP2]] ]
39 ; CHECK-NEXT: [[NITER:%.*]] = phi i64 [ 0, [[ENTRY2_NEW]] ], [ [[NITER_NEXT_7:%.*]], [[LOOP2]] ]
40 ; CHECK-NEXT: [[INC_7]] = add i64 [[PHI]], 8
41 ; CHECK-NEXT: [[NITER_NEXT_7]] = add i64 [[NITER]], 8
42 ; CHECK-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i64 [[NITER_NEXT_7]], [[UNROLL_ITER]]
43 ; CHECK-NEXT: br i1 [[NITER_NCMP_7]], label [[EXIT2_UNR_LCSSA_LOOPEXIT:%.*]], label [[LOOP2]]
44 ; CHECK: exit2.unr-lcssa.loopexit:
45 ; CHECK-NEXT: [[PHI_UNR_PH:%.*]] = phi i64 [ [[INC_7]], [[LOOP2]] ]
46 ; CHECK-NEXT: br label [[EXIT2_UNR_LCSSA]]
47 ; CHECK: exit2.unr-lcssa:
48 ; CHECK-NEXT: [[PHI_UNR:%.*]] = phi i64 [ 0, [[ENTRY2]] ], [ [[PHI_UNR_PH]], [[EXIT2_UNR_LCSSA_LOOPEXIT]] ]
49 ; CHECK-NEXT: [[LCMP_MOD:%.*]] = icmp ne i64 [[XTRAITER]], 0
50 ; CHECK-NEXT: br i1 [[LCMP_MOD]], label [[LOOP2_EPIL_PREHEADER:%.*]], label [[EXIT2:%.*]]
51 ; CHECK: loop2.epil.preheader:
52 ; CHECK-NEXT: br label [[LOOP2_EPIL:%.*]]
54 ; CHECK-NEXT: [[PHI_EPIL:%.*]] = phi i64 [ [[PHI_UNR]], [[LOOP2_EPIL_PREHEADER]] ], [ [[INC_EPIL:%.*]], [[LOOP2_EPIL]] ]
55 ; CHECK-NEXT: [[EPIL_ITER:%.*]] = phi i64 [ 0, [[LOOP2_EPIL_PREHEADER]] ], [ [[EPIL_ITER_NEXT:%.*]], [[LOOP2_EPIL]] ]
56 ; CHECK-NEXT: [[INC_EPIL]] = add i64 [[PHI_EPIL]], 1
57 ; CHECK-NEXT: [[COND2_EPIL:%.*]] = icmp eq i64 [[LD_LCSSA]], [[PHI_EPIL]]
58 ; CHECK-NEXT: [[EPIL_ITER_NEXT]] = add i64 [[EPIL_ITER]], 1
59 ; CHECK-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp ne i64 [[EPIL_ITER_NEXT]], [[XTRAITER]]
60 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP]], label [[LOOP2_EPIL]], label [[EXIT2_EPILOG_LCSSA:%.*]], !llvm.loop [[LOOP6:![0-9]+]]
61 ; CHECK: exit2.epilog-lcssa:
62 ; CHECK-NEXT: br label [[EXIT2]]
64 ; CHECK-NEXT: ret i32 0
70 %ld = load i64, ptr null, align 8
71 br i1 %cond1, label %loop1, label %exit1, !prof !1
80 %phi = phi i64 [ 0, %entry2 ], [ %inc, %loop2 ]
81 %inc = add i64 %phi, 1
82 %cond2 = icmp eq i64 %ld, %phi
83 br i1 %cond2, label %exit2, label %loop2
89 !0 = !{!"function_entry_count", i64 1}
90 !1 = !{!"branch_weights", i32 123, i32 472}