1 ; RUN: llc -disable-preheader-prot=true -disable-machine-licm -machine-sink-bfi=true -mtriple=x86_64-apple-darwin < %s | FileCheck %s -check-prefix=MSINK_BFI
2 ; RUN: llc -disable-preheader-prot=true -disable-machine-licm -machine-sink-bfi=false -mtriple=x86_64-apple-darwin < %s | FileCheck %s -check-prefix=MSINK_NOBFI
4 ; Test that by changing BlockFrequencyInfo we change the order in which
5 ; machine-sink looks for successor blocks. By not using BFI, both G and B
6 ; have the same loop depth and no instructions is sinked - B is selected but
7 ; can't be used as to avoid breaking a non profitable critical edge. By using
8 ; BFI, "mul" is sinked into the less frequent block G.
9 define i32 @sink_freqinfo(i32 %a, i32 %b) nounwind uwtable ssp {
10 ; MSINK_BFI-LABEL: sink_freqinfo
12 ; MSINK_BFI-NEXT: ## %bb.
13 ; MSINK_BFI-NEXT: imull
15 ; MSINK_NOBFI-LABEL: sink_freqinfo
22 %ee = phi i32 [ 0, %entry ], [ %inc, %F ]
24 %cond0 = icmp slt i32 %xx, 0
25 br i1 %cond0, label %F, label %exit, !prof !0
28 %inc = add nsw i32 %xx, 2
29 %aa = mul nsw i32 %b, %inc
30 %exitcond = icmp slt i32 %inc, %a
31 br i1 %exitcond, label %B, label %G, !prof !1
34 %ii = add nsw i32 %aa, %a
36 %exitcond2 = icmp sge i32 %ii, %b
37 br i1 %exitcond2, label %G, label %exit, !prof !2
43 !0 = !{!"branch_weights", i32 4, i32 1}
44 !1 = !{!"branch_weights", i32 128, i32 1}
45 !2 = !{!"branch_weights", i32 1, i32 1}