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 3 4; Test that by changing BlockFrequencyInfo we change the order in which 5; machine-sink looks for sucessor 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. 9define i32 @sink_freqinfo(i32 %a, i32 %b) nounwind uwtable ssp { 10; MSINK_BFI-LABEL: sink_freqinfo 11; MSINK_BFI: jl 12; MSINK_BFI-NEXT: ## BB# 13; MSINK_BFI-NEXT: imull 14 15; MSINK_NOBFI-LABEL: sink_freqinfo 16; MSINK_NOBFI: imull 17; MSINK_NOBFI: jl 18entry: 19 br label %B 20 21B: 22 %ee = phi i32 [ 0, %entry ], [ %inc, %F ] 23 %xx = sub i32 %a, %ee 24 %cond0 = icmp slt i32 %xx, 0 25 br i1 %cond0, label %F, label %exit, !prof !0 26 27F: 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 32 33G: 34 %ii = add nsw i32 %aa, %a 35 %ll = add i32 %b, 45 36 %exitcond2 = icmp sge i32 %ii, %b 37 br i1 %exitcond2, label %G, label %exit, !prof !2 38 39exit: 40 ret i32 0 41} 42 43!0 = !{!"branch_weights", i32 4, i32 1} 44!1 = !{!"branch_weights", i32 128, i32 1} 45!2 = !{!"branch_weights", i32 1, i32 1} 46