blob: 6b066a92ccd3291f8f846429ceb95cb985a6d276 [file] [log] [blame]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
;RUN: opt -S %s -indvars | FileCheck %s
; Provide legal integer types.
target datalayout = "n8:16:32:64"
define void @foo() #0 {
; CHECK-LABEL: @foo(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: call void @bar(i32 [[INDVARS_IV]]) #1
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INDVARS_IV_NEXT]], 512
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_END:%.*]]
; CHECK: for.end:
; CHECK-NEXT: ret void
;
entry:
br label %for.body
for.body: ; preds = %entry, %for.body
%i.01 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
%conv2 = sext i16 %i.01 to i32
call void @bar(i32 %conv2) #1
%inc = add i16 %i.01, 1
%cmp = icmp slt i16 %inc, 512
br i1 %cmp, label %for.body, label %for.end
for.end: ; preds = %for.body
ret void
}
; Check that post-incrementing the backedge taken count does not overflow.
define i32 @postinc() #0 {
; CHECK-LABEL: @postinc(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[DO_BODY:%.*]]
; CHECK: do.body:
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[INDVARS_IV_NEXT:%.*]], [[DO_BODY]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-NEXT: call void @bar(i32 [[INDVARS_IV]]) #1
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[INDVARS_IV]], 255
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i32 [[INDVARS_IV]], 1
; CHECK-NEXT: br i1 [[CMP]], label [[DO_END:%.*]], label [[DO_BODY]]
; CHECK: do.end:
; CHECK-NEXT: ret i32 0
;
entry:
br label %do.body
do.body: ; preds = %do.body, %entry
%first.0 = phi i8 [ 0, %entry ], [ %inc, %do.body ]
%conv = zext i8 %first.0 to i32
call void @bar(i32 %conv) #1
%inc = add i8 %first.0, 1
%cmp = icmp eq i8 %first.0, -1
br i1 %cmp, label %do.end, label %do.body
do.end: ; preds = %do.body
ret i32 0
}
declare void @bar(i32)
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind }