blob: 3988346351728dc1d2193d6622a912a149e45871 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
; Droppable intrinsics do not count as side effects, so they do not prevent
; assuming that a mustprogress loop is finite.
define void @assume_in_loop(i64 %n, i64 %s, i1 %c) mustprogress {
; CHECK-LABEL: 'assume_in_loop'
; CHECK-NEXT: Determining loop execution counts for: @assume_in_loop
; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i64 -1
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%i.05 = phi i64 [ %add, %for.body ], [ 0, %entry ]
call void @llvm.assume(i1 %c)
%add = add nsw i64 %i.05, %s
%cmp = icmp slt i64 %add, %n
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
define void @pseudoprobe_in_loop(i64 %n, i64 %s) mustprogress {
; CHECK-LABEL: 'pseudoprobe_in_loop'
; CHECK-NEXT: Determining loop execution counts for: @pseudoprobe_in_loop
; CHECK-NEXT: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is i64 -1
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
br label %for.body
for.body:
%i.05 = phi i64 [ %add, %for.body ], [ 0, %entry ]
call void @llvm.pseudoprobe(i64 1234, i64 1, i32 0, i64 -1)
%add = add nsw i64 %i.05, %s
%cmp = icmp slt i64 %add, %n
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
; Without mustprogress, the loop cannot be assumed finite.
define void @assume_in_loop_no_mustprogress(i64 %n, i64 %s, i1 %c) {
; CHECK-LABEL: 'assume_in_loop_no_mustprogress'
; CHECK-NEXT: Determining loop execution counts for: @assume_in_loop_no_mustprogress
; 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 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Predicates:
; CHECK-NEXT: Compare predicate: %s sgt) 0
; CHECK-NEXT: Loop %for.body: Predicated constant max backedge-taken count is i64 -1
; CHECK-NEXT: Predicates:
; CHECK-NEXT: Compare predicate: %s sgt) 0
; CHECK-NEXT: Loop %for.body: Predicated symbolic max backedge-taken count is ((((-1 * (1 umin ((-1 * %s) + (%n smax %s))))<nuw><nsw> + (-1 * %s) + (%n smax %s)) /u (1 umax %s)) + (1 umin ((-1 * %s) + (%n smax %s))))
; CHECK-NEXT: Predicates:
; CHECK-NEXT: Compare predicate: %s sgt) 0
;
entry:
br label %for.body
for.body:
%i.05 = phi i64 [ %add, %for.body ], [ 0, %entry ]
call void @llvm.assume(i1 %c)
%add = add nsw i64 %i.05, %s
%cmp = icmp slt i64 %add, %n
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
; A volatile store is a side effect.
define void @assume_and_volatile_store_in_loop(ptr %A, i64 %n, i64 %s, i1 %c) mustprogress {
; CHECK-LABEL: 'assume_and_volatile_store_in_loop'
; CHECK-NEXT: Determining loop execution counts for: @assume_and_volatile_store_in_loop
; 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:
%i.05 = phi i64 [ %add, %for.body ], [ 0, %entry ]
call void @llvm.assume(i1 %c)
%arrayidx = getelementptr inbounds i64, ptr %A, i64 %i.05
store volatile i64 0, ptr %arrayidx, align 8
%add = add nsw i64 %i.05, %s
%cmp = icmp slt i64 %add, %n
br i1 %cmp, label %for.body, label %for.end
for.end:
ret void
}
declare void @llvm.assume(i1)
declare void @llvm.pseudoprobe(i64, i64, i32, i64)