llvm/llvm/test/Transforms/LoopUnroll/loop-block-disposition-after-loop-peeling.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
; RUN: opt -S -passes='print<scalar-evolution>,loop(loop-unroll-full)' -verify-scev < %s 2>/dev/null | FileCheck %s

define i32 @test(ptr %arg) {
; CHECK-LABEL: define i32 @test
; CHECK-SAME: (ptr [[ARG:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    br label [[LOOP_PEEL_BEGIN:%.*]]
; CHECK:       loop.peel.begin:
; CHECK-NEXT:    br label [[LOOP_PEEL:%.*]]
; CHECK:       loop.peel:
; CHECK-NEXT:    [[LOAD_PEEL:%.*]] = load i32, ptr null, align 4
; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT:%.*]], label [[LOOP_LATCH_PEEL:%.*]]
; CHECK:       loop.latch.peel:
; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT]], label [[LOOP_PEEL_NEXT:%.*]]
; CHECK:       loop.peel.next:
; CHECK-NEXT:    br label [[LOOP_PEEL_NEXT1:%.*]]
; CHECK:       loop.peel.next1:
; CHECK-NEXT:    br label [[ENTRY_PEEL_NEWPH:%.*]]
; CHECK:       entry.peel.newph:
; CHECK-NEXT:    br label [[LOOP:%.*]]
; CHECK:       loop:
; CHECK-NEXT:    [[LOAD:%.*]] = load i32, ptr null, align 4
; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT_LOOPEXIT:%.*]], label [[LOOP_LATCH:%.*]]
; CHECK:       loop.latch:
; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT_LOOPEXIT]], label [[LOOP]], !llvm.loop [[LOOP0:![0-9]+]]
; CHECK:       loop.exit.loopexit:
; CHECK-NEXT:    [[EXITVAL_PH:%.*]] = phi i32 [ [[LOAD]], [[LOOP]] ], [ 0, [[LOOP_LATCH]] ]
; CHECK-NEXT:    br label [[LOOP_EXIT]]
; CHECK:       loop.exit:
; CHECK-NEXT:    [[EXITVAL:%.*]] = phi i32 [ [[LOAD_PEEL]], [[LOOP_PEEL]] ], [ 0, [[LOOP_LATCH_PEEL]] ], [ [[EXITVAL_PH]], [[LOOP_EXIT_LOOPEXIT]] ]
; CHECK-NEXT:    ret i32 [[EXITVAL]]
;
entry:
  br label %loop

loop:
  %iv = phi ptr [ %arg, %loop.latch ], [ null, %entry ]
  %load = load i32, ptr null, align 4
  br i1 false, label %loop.exit, label %loop.latch

loop.latch:
  br i1 false, label %loop.exit, label %loop

loop.exit:
  %exitval = phi i32 [ 0, %loop.latch ], [ %load, %loop ]
  ret i32 %exitval
}