158 lines · plain
1; RUN: split-file %s %t2; RUN: cat %t/main.ll %t/probable-or.prof > %t/probable-or.ll3; RUN: cat %t/main.ll %t/probable-and.prof > %t/probable-and.ll4; RUN: opt -passes='loop-mssa(simple-loop-unswitch)' -S %t/probable-or.ll -o - | FileCheck %t/probable-or.prof5; RUN: opt -passes='loop-mssa(simple-loop-unswitch)' -S %t/probable-and.ll -o - | FileCheck %t/probable-and.prof6;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-REF9 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-CHK12 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-REF15 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-CHK18 19;--- main.ll20declare void @some_func() noreturn21 22define i32 @or(i1 %cond1, i32 %var1) !prof !0 {23entry:24 br label %loop_begin25 26loop_begin:27 %var3 = phi i32 [%var1, %entry], [%var2, %do_something]28 %cond2 = icmp eq i32 %var3, 1029 %cond.or = or i1 %cond1, %cond230 br i1 %cond.or, label %loop_exit, label %do_something, !prof !131 32do_something:33 %var2 = add i32 %var3, 134 call void @some_func() noreturn nounwind35 br label %loop_begin36 37loop_exit:38 ret i32 039}40 41define i32 @and(i1 %cond1, i32 %var1) !prof !0 {42entry:43 br label %loop_begin44 45loop_begin:46 %var3 = phi i32 [%var1, %entry], [%var2, %do_something]47 %cond2 = icmp eq i32 %var3, 1048 %cond.and = and i1 %cond1, %cond249 br i1 %cond.and, label %do_something, label %loop_exit, !prof !150 51do_something:52 %var2 = add i32 %var3, 153 call void @some_func() noreturn nounwind54 br label %loop_begin55 56loop_exit:57 ret i32 058}59 60;--- probable-or.prof61!0 = !{!"function_entry_count", i32 10}62!1 = !{!"branch_weights", i32 1, i32 1000}63; CHECK-LABEL: @or64; CHECK-LABEL: entry:65; CHECK-NEXT: %cond1.fr = freeze i1 %cond166; CHECK-NEXT: br i1 %cond1.fr, label %loop_exit.split, label %entry.split, !prof !167; CHECK-LABEL: @and68; CHECK-LABEL: entry:69; CHECK-NEXT: %cond1.fr = freeze i1 %cond170; CHECK-NEXT: br i1 %cond1.fr, label %entry.split, label %loop_exit.split, !prof !271; 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: or76 ; PROFILE-COM: - entry: {{.*}} count = 1077 ; PROFILE-COM: - loop_begin: {{.*}} count = 1001078 ; PROFILE-COM: - do_something: {{.*}} count = 1000079 ; PROFILE-COM: - loop_exit: {{.*}} count = 1080 81; PROFILE-COM: Printing analysis results of BFI for function 'and':82; PROFILE-COM: block-frequency-info: and83 ; PROFILE-COM: - entry: {{.*}} count = 1084 ; PROFILE-COM: - loop_begin: {{.*}} count = 1085 ; PROFILE-COM: - do_something: {{.*}} count = 086 ; PROFILE-COM: - loop_exit: {{.*}} count = 1087 88; PROFILE-COM: Printing analysis results of BFI for function 'or':89; PROFILE-COM: block-frequency-info: or90 ; PROFILE-COM: - entry: {{.*}} count = 1091 ; PROFILE-REF: - entry.split: {{.*}} count = 592 ; PROFILE-CHK: - entry.split: {{.*}} count = 1093 ; PROFILE-REF: - loop_begin: {{.*}} count = 500594 ; PROFILE-CHK: - loop_begin: {{.*}} count = 1000095 ; PROFILE-REF: - do_something: {{.*}} count = 500096 ; PROFILE-CHK: - do_something: {{.*}} count = 999097 ; PROFILE-REF: - loop_exit: {{.*}} count = 598 ; PROFILE-CHK: - loop_exit: {{.*}} count = 1099 ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10100 101; PROFILE-COM: Printing analysis results of BFI for function 'and':102; PROFILE-COM: block-frequency-info: and103 ; PROFILE-COM: - entry: {{.*}} count = 10104 ; PROFILE-COM: - entry.split: {{.*}} count = 5105 ; PROFILE-COM: - loop_begin: {{.*}} count = 5106 ; PROFILE-COM: - do_something: {{.*}} count = 0107 ; PROFILE-COM: - loop_exit: {{.*}} count = 5108 ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10109 110;--- probable-and.prof111!0 = !{!"function_entry_count", i32 10}112!1 = !{!"branch_weights", i32 1000, i32 1}113; CHECK-LABEL: @or114; CHECK-LABEL: entry:115; CHECK-NEXT: %cond1.fr = freeze i1 %cond1116; CHECK-NEXT: br i1 %cond1.fr, label %loop_exit.split, label %entry.split, !prof !1117; CHECK-LABEL: @and118; CHECK-LABEL: entry:119; CHECK-NEXT: %cond1.fr = freeze i1 %cond1120; CHECK-NEXT: br i1 %cond1.fr, label %entry.split, label %loop_exit.split, !prof !2121; 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: or125 ; PROFILE-COM: - entry: {{.*}}, count = 10126 ; PROFILE-COM: - loop_begin: {{.*}}, count = 10127 ; PROFILE-COM: - do_something: {{.*}}, count = 0128 ; PROFILE-COM: - loop_exit: {{.*}}, count = 10129 130; PROFILE-COM: Printing analysis results of BFI for function 'and':131; PROFILE-COM: block-frequency-info: and132 ; PROFILE-COM: - entry: {{.*}} count = 10133 ; PROFILE-COM: - loop_begin: {{.*}} count = 10010134 ; PROFILE-COM: - do_something: {{.*}} count = 10000135 ; PROFILE-COM: - loop_exit: {{.*}} count = 10136 137; PROFILE-COM: Printing analysis results of BFI for function 'or':138; PROFILE-COM: block-frequency-info: or139 ; PROFILE-COM: - entry: {{.*}} count = 10140 ; PROFILE-COM: - entry.split: {{.*}} count = 5141 ; PROFILE-COM: - loop_begin: {{.*}} count = 5142 ; PROFILE-COM: - do_something: {{.*}} count = 0143 ; PROFILE-COM: - loop_exit: {{.*}} count = 5144 ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10145 146; PROFILE-COM: Printing analysis results of BFI for function 'and':147; PROFILE-COM: block-frequency-info: and148 ; PROFILE-COM: - entry: {{.*}} count = 10149 ; PROFILE-REF: - entry.split: {{.*}} count = 5150 ; PROFILE-CHK: - entry.split: {{.*}} count = 10151 ; PROFILE-REF: - loop_begin: {{.*}} count = 5005152 ; PROFILE-CHK: - loop_begin: {{.*}} count = 10000153 ; PROFILE-REF: - do_something: {{.*}} count = 5000154 ; PROFILE-CHK: - do_something: {{.*}} count = 9990155 ; PROFILE-REF: - loop_exit: {{.*}} count = 5156 ; PROFILE-CHK: - loop_exit: {{.*}} count = 10157 ; PROFILE-COM: - loop_exit.split: {{.*}} count = 10158