1 ; RUN: opt < %s -S -loop-unroll -unroll-force-peel-count=1 | FileCheck %s
3 ; Check we don't peel loops where the latch is not the exiting block.
4 ; CHECK-LABEL: @invariant_backedge_irreducible
6 ; CHECK: br label %header
9 ; CHECK: br i1 {{.*}} label %latch, label %exiting
11 ; CHECK: br i1 {{.*}} label %header, label %exiting
13 ; CHECK: br i1 {{.*}} label %latch, label %exit
15 define i32 @invariant_backedge_irreducible(i32 %a, i32 %b) {
20 %i = phi i32 [ 0, %entry ], [ %inc, %latch ]
21 %cmp.phi = phi i1 [ false, %entry ], [ %cmp, %latch ]
22 br i1 %cmp.phi, label %latch, label %exiting
26 %cmp = icmp slt i32 %i, 1000
27 br i1 %cmp, label %header, label %exiting
30 %cmp.exiting = phi i1 [ %cmp.phi, %header ], [ %cmp, %latch ]
31 br i1 %cmp.exiting, label %latch, label %exit