• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>,loop-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 2!
9
10define i32 @basic(i32* %p, i32 %k, i1 %c1, i1 %c2) #0 !prof !3 {
11entry:
12  %cmp3 = icmp slt i32 0, %k
13  br i1 %cmp3, label %for.body.lr.ph, label %for.end
14
15for.body.lr.ph:                                   ; preds = %entry
16  br label %for.body
17
18for.body:                                         ; preds = %for.body.lr.ph, %for.body
19  %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %latch ]
20  %p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %latch ]
21  %incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1
22  store i32 %i.05, i32* %p.addr.04, align 4
23  %inc = add nsw i32 %i.05, 1
24  %cmp = icmp slt i32 %inc, %k
25  br i1 %c1, label %continue, label %to_side_exit
26
27continue:
28  br i1 %c2, label %latch, label %side_exit, !prof !2
29
30latch:
31  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !1
32
33for.cond.for.end_crit_edge:                       ; preds = %for.body
34  br label %for.end
35
36to_side_exit:
37  br i1 %c2, label %continue, label %side_exit, !prof !2
38
39
40for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
41  %res = phi i32 [ 0, %entry ], [ %inc, %for.cond.for.end_crit_edge ]
42  ret i32 %res
43
44side_exit:
45  %rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 %inc) ]
46  ret i32 %rval
47}
48
49declare i32 @llvm.experimental.deoptimize.i32(...)
50
51attributes #0 = { nounwind }
52
53!1 = !{!"branch_weights", i32 1, i32 1}
54!2 = !{!"branch_weights", i32 1, i32 0}
55!3 = !{!"function_entry_count", i64 1}
56