blob: c1ebe57676a1f0f2d2834e3cf5a45d5d93769476 [file] [edit]
; RUN: opt -passes='function(require<assumptions>,loop(loop-bound-split),print<assumptions>)' -disable-output %s 2>&1 | FileCheck %s
; %iv < umax(%a, 1) holds for a prefix of the iterations, so the loop is split
; into a pre-loop and a cloned post-loop. The copy of the assume in the post-loop
; must be in the cache.
; CHECK-LABEL: Cached assumptions for function: f
; CHECK-DAG: %c = icmp ult i64 %k, 100
; CHECK-DAG: %c.split = icmp ult i64 %k, 100
define void @f(i64 %a, ptr noalias %src, ptr noalias %dst, i64 %n, i64 %k) {
loop.ph:
%b = call i64 @llvm.umax.i64(i64 %a, i64 1)
br label %loop
loop:
%iv = phi i64 [ %inc, %for.inc ], [ 0, %loop.ph ]
%c = icmp ult i64 %k, 100
call void @llvm.assume(i1 %c)
%cmp = icmp ult i64 %iv, %b
br i1 %cmp, label %if.then, label %if.else
if.then:
%src.p = getelementptr inbounds i64, ptr %src, i64 %iv
%val = load i64, ptr %src.p, align 4
%dst.p = getelementptr inbounds i64, ptr %dst, i64 %iv
store i64 %val, ptr %dst.p, align 4
br label %for.inc
if.else:
br label %for.inc
for.inc:
%inc = add nuw nsw i64 %iv, 1
%cond = icmp sgt i64 %inc, %n
br i1 %cond, label %exit, label %loop
exit:
ret void
}