[LoopVectorizer] Refine loop vectorizer's register usage calculator by ignoring speci...
[oota-llvm.git] / test / Transforms / LoopUnswitch / cold-loop.ll
1 ; RUN: opt < %s -loop-unswitch -loop-unswitch-with-block-frequency -S 2>&1 | FileCheck %s
2
3 ;; trivial condition should be unswithed regardless of coldness.
4 define i32 @test1(i1 %cond1, i1 %cond2) !prof !1 {
5   br i1 %cond1, label %loop_begin, label %loop_exit, !prof !0
6
7 loop_begin:
8 ; CHECK: br i1 true, label %continue, label %loop_exit.loopexit
9   br i1 %cond2, label %continue, label %loop_exit  ; trivial condition
10
11 continue:
12   call void @some_func1() noreturn nounwind
13   br label %loop_begin
14
15 loop_exit:
16   ret i32 0
17 }
18
19 ;; cold non-trivial condition should not be unswitched.
20 define i32 @test2(i32* %var, i1 %cond1, i1 %cond2) !prof !1 {
21   br i1 %cond1, label %loop_begin, label %loop_exit, !prof !0
22
23 loop_begin:
24   store i32 1, i32* %var
25 ; CHECK: br i1 %cond2, label %continue1, label %continue2
26   br i1 %cond2, label %continue1, label %continue2  ; non-trivial condition
27
28 continue1:
29   call void @some_func1() noreturn nounwind
30   br label %joint
31
32 continue2:
33   call void @some_func2() noreturn nounwind
34   br label %joint
35
36 joint:
37 ;; unswitching will duplicate these calls.
38   call void @some_func3() noreturn nounwind
39   call void @some_func4() noreturn nounwind
40   br label %loop_begin
41
42 loop_exit:
43   ret i32 0
44 }
45
46 declare void @some_func1() noreturn
47 declare void @some_func2() noreturn
48 declare void @some_func3() noreturn
49 declare void @some_func4() noreturn
50
51 !0 = !{!"branch_weights", i32 1, i32 100000000}
52 !1 = !{!"function_entry_count", i64 100}