; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=indvars < %s | FileCheck %s
; This test used to assert when expanding an addrec into a loop without
; preheader.
define void @test(ptr %tgt) {
; CHECK-LABEL: @test(
; CHECK-NEXT: bb31:
; CHECK-NEXT: indirectbr ptr [[TGT:%.*]], [label [[EXIT:%.*]], label %bb33]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: bb33:
; CHECK-NEXT: [[TMP34:%.*]] = phi i32 [ [[TMP50:%.*]], [[BB49:%.*]] ], [ 0, [[BB31:%.*]] ]
; CHECK-NEXT: br i1 false, label [[BB40_PREHEADER:%.*]], label [[BB49]]
; CHECK: bb40.preheader:
; CHECK-NEXT: br label [[BB40:%.*]]
; CHECK: bb40:
; CHECK-NEXT: br label [[BB40]]
; CHECK: bb49:
; CHECK-NEXT: [[TMP50]] = add i32 [[TMP34]], 1
; CHECK-NEXT: br label [[BB33:%.*]]
;
bb31:
indirectbr ptr %tgt, [label %exit, label %bb33]
exit:
ret void
bb33: ; preds = %bb49, %bb31
%tmp34 = phi i32 [ %tmp50, %bb49 ], [ 0, %bb31 ]
%tmp36 = add i32 %tmp34, 1
br i1 false, label %bb40, label %bb49
bb40: ; preds = %bb38, %bb37
%tmp41 = phi i32 [ %tmp36, %bb33 ], [ %tmp39, %bb40 ]
%tmp39 = add i32 %tmp41, 0
br label %bb40
bb49: ; preds = %bb35
%tmp50 = add i32 %tmp34, 1
br label %bb33
}