|
| 1 | +; RUN: split-file %s %t |
| 2 | +; RUN: cat %t/main.ll %t/probable-or.prof > %t/probable-or.ll |
| 3 | +; RUN: cat %t/main.ll %t/probable-and.prof > %t/probable-and.ll |
| 4 | +; RUN: opt -passes='loop-mssa(simple-loop-unswitch)' -S %t/probable-or.ll -o - | FileCheck %t/probable-or.prof |
| 5 | +; RUN: opt -passes='loop-mssa(simple-loop-unswitch)' -S %t/probable-and.ll -o - | FileCheck %t/probable-and.prof |
| 6 | +; |
| 7 | +; RUN: opt -passes='module(print<block-freq>),function(loop-mssa(simple-loop-unswitch)),module(print<block-freq>)' \ |
| 8 | +; RUN: %t/probable-or.ll -disable-output -simple-loop-unswitch-estimate-profile=0 2>&1 | FileCheck %t/probable-or.prof --check-prefixes=PROFILE-COM,PROFILE-REF |
| 9 | + |
| 10 | +; RUN: opt -passes='module(print<block-freq>),function(loop-mssa(simple-loop-unswitch)),module(print<block-freq>)' \ |
| 11 | +; RUN: %t/probable-or.ll -disable-output -simple-loop-unswitch-estimate-profile=1 2>&1 | FileCheck %t/probable-or.prof --check-prefixes=PROFILE-COM,PROFILE-CHK |
| 12 | + |
| 13 | +; RUN: opt -passes='module(print<block-freq>),function(loop-mssa(simple-loop-unswitch)),module(print<block-freq>)' \ |
| 14 | +; RUN: %t/probable-and.ll -disable-output -simple-loop-unswitch-estimate-profile=0 2>&1 | FileCheck %t/probable-and.prof --check-prefixes=PROFILE-COM,PROFILE-REF |
| 15 | + |
| 16 | +; RUN: opt -passes='module(print<block-freq>),function(loop-mssa(simple-loop-unswitch)),module(print<block-freq>)' \ |
| 17 | +; RUN: %t/probable-and.ll -disable-output -simple-loop-unswitch-estimate-profile=1 2>&1 | FileCheck %t/probable-and.prof --check-prefixes=PROFILE-COM,PROFILE-CHK |
| 18 | + |
| 19 | +;--- main.ll |
| 20 | +declare void @some_func() noreturn |
| 21 | + |
| 22 | +define i32 @or(i1 %cond1, i32 %var1) !prof !0 { |
| 23 | +entry: |
| 24 | + br label %loop_begin |
| 25 | + |
| 26 | +loop_begin: |
| 27 | + %var3 = phi i32 [%var1, %entry], [%var2, %do_something] |
| 28 | + %cond2 = icmp eq i32 %var3, 10 |
| 29 | + %cond.or = or i1 %cond1, %cond2 |
| 30 | + br i1 %cond.or, label %loop_exit, label %do_something, !prof !1 |
| 31 | + |
| 32 | +do_something: |
| 33 | + %var2 = add i32 %var3, 1 |
| 34 | + call void @some_func() noreturn nounwind |
| 35 | + br label %loop_begin |
| 36 | + |
| 37 | +loop_exit: |
| 38 | + ret i32 0 |
| 39 | +} |
| 40 | + |
| 41 | +define i32 @and(i1 %cond1, i32 %var1) !prof !0 { |
| 42 | +entry: |
| 43 | + br label %loop_begin |
| 44 | + |
| 45 | +loop_begin: |
| 46 | + %var3 = phi i32 [%var1, %entry], [%var2, %do_something] |
| 47 | + %cond2 = icmp eq i32 %var3, 10 |
| 48 | + %cond.and = and i1 %cond1, %cond2 |
| 49 | + br i1 %cond.and, label %do_something, label %loop_exit, !prof !1 |
| 50 | + |
| 51 | +do_something: |
| 52 | + %var2 = add i32 %var3, 1 |
| 53 | + call void @some_func() noreturn nounwind |
| 54 | + br label %loop_begin |
| 55 | + |
| 56 | +loop_exit: |
| 57 | + ret i32 0 |
| 58 | +} |
| 59 | + |
| 60 | +;--- probable-or.prof |
| 61 | +!0 = !{!"function_entry_count", i32 10} |
| 62 | +!1 = !{!"branch_weights", i32 1, i32 1000} |
| 63 | +; CHECK-LABEL: @or |
| 64 | +; CHECK-LABEL: entry: |
| 65 | +; CHECK-NEXT: %cond1.fr = freeze i1 %cond1 |
| 66 | +; CHECK-NEXT: br i1 %cond1.fr, label %loop_exit.split, label %entry.split, !prof !1 |
| 67 | +; CHECK-LABEL: @and |
| 68 | +; CHECK-LABEL: entry: |
| 69 | +; CHECK-NEXT: %cond1.fr = freeze i1 %cond1 |
| 70 | +; CHECK-NEXT: br i1 %cond1.fr, label %entry.split, label %loop_exit.split, !prof !2 |
| 71 | +; CHECK: !1 = !{!"branch_weights", i32 1, i32 1000} |
| 72 | +; CHECK: !2 = !{!"unknown", !"simple-loop-unswitch"} |
| 73 | + |
| 74 | +; PROFILE-COM: Printing analysis results of BFI for function 'or': |
| 75 | +; PROFILE-COM: block-frequency-info: or |
| 76 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 77 | + ; PROFILE-COM: - loop_begin: {{.*}} count = 10010 |
| 78 | + ; PROFILE-COM: - do_something: {{.*}} count = 10000 |
| 79 | + ; PROFILE-COM: - loop_exit: {{.*}} count = 10 |
| 80 | + |
| 81 | +; PROFILE-COM: Printing analysis results of BFI for function 'and': |
| 82 | +; PROFILE-COM: block-frequency-info: and |
| 83 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 84 | + ; PROFILE-COM: - loop_begin: {{.*}} count = 10 |
| 85 | + ; PROFILE-COM: - do_something: {{.*}} count = 0 |
| 86 | + ; PROFILE-COM: - loop_exit: {{.*}} count = 10 |
| 87 | + |
| 88 | +; PROFILE-COM: Printing analysis results of BFI for function 'or': |
| 89 | +; PROFILE-COM: block-frequency-info: or |
| 90 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 91 | + ; PROFILE-REF: - entry.split: {{.*}} count = 5 |
| 92 | + ; PROFILE-CHK: - entry.split: {{.*}} count = 10 |
| 93 | + ; PROFILE-REF: - loop_begin: {{.*}} count = 5005 |
| 94 | + ; PROFILE-CHK: - loop_begin: {{.*}} count = 10000 |
| 95 | + ; PROFILE-REF: - do_something: {{.*}} count = 5000 |
| 96 | + ; PROFILE-CHK: - do_something: {{.*}} count = 9990 |
| 97 | + ; PROFILE-REF: - loop_exit: {{.*}} count = 5 |
| 98 | + ; PROFILE-CHK: - loop_exit: {{.*}} count = 10 |
| 99 | + ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10 |
| 100 | + |
| 101 | +; PROFILE-COM: Printing analysis results of BFI for function 'and': |
| 102 | +; PROFILE-COM: block-frequency-info: and |
| 103 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 104 | + ; PROFILE-COM: - entry.split: {{.*}} count = 5 |
| 105 | + ; PROFILE-COM: - loop_begin: {{.*}} count = 5 |
| 106 | + ; PROFILE-COM: - do_something: {{.*}} count = 0 |
| 107 | + ; PROFILE-COM: - loop_exit: {{.*}} count = 5 |
| 108 | + ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10 |
| 109 | + |
| 110 | +;--- probable-and.prof |
| 111 | +!0 = !{!"function_entry_count", i32 10} |
| 112 | +!1 = !{!"branch_weights", i32 1000, i32 1} |
| 113 | +; CHECK-LABEL: @or |
| 114 | +; CHECK-LABEL: entry: |
| 115 | +; CHECK-NEXT: %cond1.fr = freeze i1 %cond1 |
| 116 | +; CHECK-NEXT: br i1 %cond1.fr, label %loop_exit.split, label %entry.split, !prof !1 |
| 117 | +; CHECK-LABEL: @and |
| 118 | +; CHECK-LABEL: entry: |
| 119 | +; CHECK-NEXT: %cond1.fr = freeze i1 %cond1 |
| 120 | +; CHECK-NEXT: br i1 %cond1.fr, label %entry.split, label %loop_exit.split, !prof !2 |
| 121 | +; CHECK: !1 = !{!"unknown", !"simple-loop-unswitch"} |
| 122 | +; CHECK: !2 = !{!"branch_weights", i32 1000, i32 1} |
| 123 | +; PROFILE-COM: Printing analysis results of BFI for function 'or': |
| 124 | +; PROFILE-COM: block-frequency-info: or |
| 125 | + ; PROFILE-COM: - entry: {{.*}}, count = 10 |
| 126 | + ; PROFILE-COM: - loop_begin: {{.*}}, count = 10 |
| 127 | + ; PROFILE-COM: - do_something: {{.*}}, count = 0 |
| 128 | + ; PROFILE-COM: - loop_exit: {{.*}}, count = 10 |
| 129 | + |
| 130 | +; PROFILE-COM: Printing analysis results of BFI for function 'and': |
| 131 | +; PROFILE-COM: block-frequency-info: and |
| 132 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 133 | + ; PROFILE-COM: - loop_begin: {{.*}} count = 10010 |
| 134 | + ; PROFILE-COM: - do_something: {{.*}} count = 10000 |
| 135 | + ; PROFILE-COM: - loop_exit: {{.*}} count = 10 |
| 136 | + |
| 137 | +; PROFILE-COM: Printing analysis results of BFI for function 'or': |
| 138 | +; PROFILE-COM: block-frequency-info: or |
| 139 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 140 | + ; PROFILE-COM: - entry.split: {{.*}} count = 5 |
| 141 | + ; PROFILE-COM: - loop_begin: {{.*}} count = 5 |
| 142 | + ; PROFILE-COM: - do_something: {{.*}} count = 0 |
| 143 | + ; PROFILE-COM: - loop_exit: {{.*}} count = 5 |
| 144 | + ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10 |
| 145 | + |
| 146 | +; PROFILE-COM: Printing analysis results of BFI for function 'and': |
| 147 | +; PROFILE-COM: block-frequency-info: and |
| 148 | + ; PROFILE-COM: - entry: {{.*}} count = 10 |
| 149 | + ; PROFILE-REF: - entry.split: {{.*}} count = 5 |
| 150 | + ; PROFILE-CHK: - entry.split: {{.*}} count = 10 |
| 151 | + ; PROFILE-REF: - loop_begin: {{.*}} count = 5005 |
| 152 | + ; PROFILE-CHK: - loop_begin: {{.*}} count = 10000 |
| 153 | + ; PROFILE-REF: - do_something: {{.*}} count = 5000 |
| 154 | + ; PROFILE-CHK: - do_something: {{.*}} count = 9990 |
| 155 | + ; PROFILE-REF: - loop_exit: {{.*}} count = 5 |
| 156 | + ; PROFILE-CHK: - loop_exit: {{.*}} count = 10 |
| 157 | + ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10 |
0 commit comments