|
| 1 | +; REQUIRES: asserts |
| 2 | +; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll -unroll-runtime -unroll-peel-multi-deopt-exit 2>&1 | FileCheck %s |
| 3 | +; RUN: opt < %s -S -debug-only=loop-unroll -unroll-peel-multi-deopt-exit -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s |
| 4 | + |
| 5 | +; Regression test for setting the correct idom for exit blocks. |
| 6 | + |
| 7 | +; CHECK: Loop Unroll: F[basic] |
| 8 | +; CHECK: PEELING loop %for.body with iteration count 1! |
| 9 | + |
| 10 | +define i32 @basic(i32* %p, i32 %k, i1 %c1, i1 %c2) #0 !prof !3 { |
| 11 | +entry: |
| 12 | + br label %for.body |
| 13 | + |
| 14 | +for.body: |
| 15 | + %i.05 = phi i32 [ 0, %entry ], [ %inc, %latch ] |
| 16 | + %p.addr.04 = phi i32* [ %p, %entry ], [ %incdec.ptr, %latch ] |
| 17 | + %incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1 |
| 18 | + store i32 %i.05, i32* %p.addr.04, align 4 |
| 19 | + %inc = add nsw i32 %i.05, 1 |
| 20 | + %cmp = icmp slt i32 %inc, %k |
| 21 | + br i1 %c1, label %left, label %right |
| 22 | + |
| 23 | +left: |
| 24 | + br label %latch |
| 25 | + |
| 26 | +right: |
| 27 | + br i1 %c1, label %latch, label %side_exit, !prof !2 |
| 28 | + |
| 29 | +latch: |
| 30 | + br i1 %cmp, label %for.body, label %for.end, !prof !1 |
| 31 | + |
| 32 | +for.end: |
| 33 | + ret i32 %inc |
| 34 | + |
| 35 | +side_exit: |
| 36 | + %rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 %inc) ] |
| 37 | + ret i32 %rval |
| 38 | +} |
| 39 | + |
| 40 | +declare i32 @llvm.experimental.deoptimize.i32(...) |
| 41 | + |
| 42 | +attributes #0 = { nounwind } |
| 43 | + |
| 44 | +!1 = !{!"branch_weights", i32 1, i32 1} |
| 45 | +!2 = !{!"branch_weights", i32 1, i32 0} |
| 46 | +!3 = !{!"function_entry_count", i64 1} |
0 commit comments