; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-max-iterations=0 -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare void @non_exit_use(i32 %i) #0
define void @sle_pre_inc(i32 %len) willreturn {
; CHECK-LABEL: 'sle_pre_inc'
; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (0 smax (1 + %len))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 2147483647
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (0 smax (1 + %len))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp sle i32 %iv, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @sle_post_inc(i32 %len) willreturn {
; CHECK-LABEL: 'sle_post_inc'
; CHECK-NEXT: Determining loop execution counts for: @sle_post_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 2147483646
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp sle i32 %inc, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @sle_pre_inc_infinite(i32 %len) {
; CHECK-LABEL: 'sle_pre_inc_infinite'
; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (0 smax (1 + (sext i32 %len to i64))<nsw>)
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nssw>
; CHECK-NEXT: Loop %for.body: Predicated constant max backedge-taken count is i64 2147483648
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nssw>
; CHECK-NEXT: Loop %for.body: Predicated symbolic max backedge-taken count is (0 smax (1 + (sext i32 %len to i64))<nsw>)
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nssw>
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp sle i32 %iv, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @ule_pre_inc(i32 %len) willreturn {
; CHECK-LABEL: 'ule_pre_inc'
; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (1 + %len)
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 -1
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (1 + %len)
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp ule i32 %iv, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @ule_post_inc(i32 %len) willreturn {
; CHECK-LABEL: 'ule_post_inc'
; CHECK-NEXT: Determining loop execution counts for: @ule_post_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax (1 + %len)))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 -2
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 umax (1 + %len)))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp ule i32 %inc, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @ule_pre_inc_infinite(i32 %len) {
; CHECK-LABEL: 'ule_pre_inc_infinite'
; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (1 + (zext i32 %len to i64))<nuw><nsw>
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nusw>
; CHECK-NEXT: Loop %for.body: Predicated constant max backedge-taken count is i64 4294967296
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nusw>
; CHECK-NEXT: Loop %for.body: Predicated symbolic max backedge-taken count is (1 + (zext i32 %len to i64))<nuw><nsw>
; CHECK-NEXT: Predicates:
; CHECK-NEXT: {0,+,1}<%for.body> Added Flags: <nusw>
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, 1
%cmp = icmp ule i32 %iv, %len
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @sge_pre_inc(i32 %end) willreturn {
; CHECK-LABEL: 'sge_pre_inc'
; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 -2147483548
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp sge i32 %iv, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @sge_post_inc(i32 %end) willreturn {
; CHECK-LABEL: 'sge_post_inc'
; CHECK-NEXT: Determining loop execution counts for: @sge_post_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 -2147483548
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp sge i32 %iv, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @sge_pre_inc_infinite(i32 %end) {
; CHECK-LABEL: 'sge_pre_inc_infinite'
; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp sge i32 %iv, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @use_pre_inc(i32 %end) willreturn {
; CHECK-LABEL: 'use_pre_inc'
; CHECK-NEXT: Determining loop execution counts for: @use_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 100
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp uge i32 %iv, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @use_post_inc(i32 %end) willreturn {
; CHECK-LABEL: 'use_post_inc'
; CHECK-NEXT: Determining loop execution counts for: @use_post_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i32 99
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp uge i32 %inc, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @uge_pre_inc_infinite(i32 %end) {
; CHECK-LABEL: 'uge_pre_inc_infinite'
; CHECK-NEXT: Determining loop execution counts for: @uge_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
;
entry:
br label %for.body
for.body:
%iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
call void @non_exit_use(i32 %iv) nounwind willreturn
%inc = add i32 %iv, -1
%cmp = icmp uge i32 %iv, %end
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @pr54191(i64 %n) mustprogress {
; CHECK-LABEL: 'pr54191'
; CHECK-NEXT: Determining loop execution counts for: @pr54191
; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + %n) /u 2)
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i64 4611686018427387902
; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-2 + %n) /u 2)
; CHECK-NEXT: Loop %loop: Trip multiple is 1
;
entry:
%guard = icmp sgt i64 %n, 1
br i1 %guard, label %loop, label %exit
loop:
%iv = phi i64 [ 2, %entry ], [ %iv.next, %loop ]
%iv.next = add nuw nsw i64 %iv, 2
%cmp = icmp sle i64 %iv.next, %n
br i1 %cmp, label %loop, label %exit
exit:
ret void
}