| ; RUN: opt -passes='function(require<assumptions>,loop-versioning,print<assumptions>)' -disable-output %s 2>&1 | FileCheck %s | |
| ; RUN: opt -passes='function(require<assumptions>,loop-load-elim,print<assumptions>)' -disable-output %s 2>&1 | FileCheck %s | |
| ; The accesses to %A, %B and %C need runtime checks, so the loop is versioned. | |
| ; The copy of the assume in the non-versioned loop must be in the cache. | |
| ; CHECK-LABEL: Cached assumptions for function: f | |
| ; CHECK-DAG: %k = icmp ult i32 %b, 100 | |
| ; CHECK-DAG: %k.lver.orig = icmp ult i32 %b.lver.orig, 100 | |
| define void @f(ptr %A, ptr %B, ptr %C, i64 %N) { | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %a.next.p = getelementptr inbounds i32, ptr %A, i64 %iv.next | |
| %b.p = getelementptr inbounds i32, ptr %B, i64 %iv | |
| %c.p = getelementptr inbounds i32, ptr %C, i64 %iv | |
| %a.p = getelementptr inbounds i32, ptr %A, i64 %iv | |
| %b = load i32, ptr %b.p, align 4 | |
| %k = icmp ult i32 %b, 100 | |
| call void @llvm.assume(i1 %k) | |
| %a.next = add i32 %b, 2 | |
| store i32 %a.next, ptr %a.next.p, align 4 | |
| %a = load i32, ptr %a.p, align 4 | |
| %c = mul i32 %a, 2 | |
| store i32 %c, ptr %c.p, align 4 | |
| %done = icmp eq i64 %iv.next, %N | |
| br i1 %done, label %exit, label %loop | |
| exit: | |
| ret void | |
| } |