1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=loop-unroll -unroll-force-peel-count=1 | FileCheck %s
4 define i32 @invariant_backedge_irreducible(i32 %a, i32 %b) {
5 ; CHECK-LABEL: @invariant_backedge_irreducible(
7 ; CHECK-NEXT: br label [[HEADER_PEEL_BEGIN:%.*]]
8 ; CHECK: header.peel.begin:
9 ; CHECK-NEXT: br label [[HEADER_PEEL:%.*]]
11 ; CHECK-NEXT: br i1 false, label [[LATCH_PEEL:%.*]], label [[EXITING_PEEL:%.*]]
13 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add i32 0, 1
14 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 0, 1000
15 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[HEADER_PEEL_NEXT:%.*]], label [[EXITING_PEEL]]
16 ; CHECK: exiting.peel:
17 ; CHECK-NEXT: [[CMP_EXITING_PEEL:%.*]] = phi i1 [ false, [[HEADER_PEEL]] ], [ [[CMP_PEEL]], [[LATCH_PEEL]] ]
18 ; CHECK-NEXT: br i1 [[CMP_EXITING_PEEL]], label [[LATCH_PEEL]], label [[EXIT:%.*]]
19 ; CHECK: header.peel.next:
20 ; CHECK-NEXT: br label [[HEADER_PEEL_NEXT1:%.*]]
21 ; CHECK: header.peel.next1:
22 ; CHECK-NEXT: br label [[ENTRY_PEEL_NEWPH:%.*]]
23 ; CHECK: entry.peel.newph:
24 ; CHECK-NEXT: br label [[HEADER:%.*]]
26 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[INC_PEEL]], [[ENTRY_PEEL_NEWPH]] ], [ [[INC:%.*]], [[LATCH:%.*]] ]
27 ; CHECK-NEXT: [[CMP_PHI:%.*]] = phi i1 [ [[CMP_PEEL]], [[ENTRY_PEEL_NEWPH]] ], [ [[CMP:%.*]], [[LATCH]] ]
28 ; CHECK-NEXT: br i1 [[CMP_PHI]], label [[LATCH]], label [[EXITING:%.*]]
30 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I]], 1
31 ; CHECK-NEXT: [[CMP]] = icmp slt i32 [[I]], 1000
32 ; CHECK-NEXT: br i1 [[CMP]], label [[HEADER]], label [[EXITING]], !llvm.loop [[LOOP0:![0-9]+]]
34 ; CHECK-NEXT: [[CMP_EXITING:%.*]] = phi i1 [ [[CMP_PHI]], [[HEADER]] ], [ [[CMP]], [[LATCH]] ]
35 ; CHECK-NEXT: br i1 [[CMP_EXITING]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
36 ; CHECK: exit.loopexit:
37 ; CHECK-NEXT: br label [[EXIT]]
39 ; CHECK-NEXT: ret i32 0
45 %i = phi i32 [ 0, %entry ], [ %inc, %latch ]
46 %cmp.phi = phi i1 [ false, %entry ], [ %cmp, %latch ]
47 br i1 %cmp.phi, label %latch, label %exiting
51 %cmp = icmp slt i32 %i, 1000
52 br i1 %cmp, label %header, label %exiting
55 %cmp.exiting = phi i1 [ %cmp.phi, %header ], [ %cmp, %latch ]
56 br i1 %cmp.exiting, label %latch, label %exit