63 lines · plain
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_BFI2; RUN: llc -disable-preheader-prot=true -disable-machine-licm -machine-sink-bfi=false -mtriple=x86_64-apple-darwin < %s | FileCheck %s -check-prefix=MSINK_NOBFI3; RUN: llc -disable-preheader-prot=true -disable-machine-licm -machine-sink-bfi=true -force-pgso -mtriple=x86_64-apple-darwin < %s | FileCheck %s -check-prefix=MSINK_NOBFI4 5; Test that by changing BlockFrequencyInfo we change the order in which6; machine-sink looks for successor blocks. By not using BFI, both G and B7; have the same loop depth and no instructions is sinked - B is selected but8; can't be used as to avoid breaking a non profitable critical edge. By using9; BFI, "mul" is sinked into the less frequent block G.10define i32 @sink_freqinfo(i32 %a, i32 %b) nounwind uwtable ssp !prof !14 {11; MSINK_BFI-LABEL: sink_freqinfo12; MSINK_BFI: jl13; MSINK_BFI-NEXT: ## %bb.14; MSINK_BFI-NEXT: imull15 16; MSINK_NOBFI-LABEL: sink_freqinfo17; MSINK_NOBFI: imull18; MSINK_NOBFI: jl19entry:20 br label %B21 22B:23 %ee = phi i32 [ 0, %entry ], [ %inc, %F ]24 %xx = sub i32 %a, %ee25 %cond0 = icmp slt i32 %xx, 026 br i1 %cond0, label %F, label %exit, !prof !1527 28F:29 %inc = add nsw i32 %xx, 230 %aa = mul nsw i32 %b, %inc31 %exitcond = icmp slt i32 %inc, %a32 br i1 %exitcond, label %B, label %G, !prof !1633 34G:35 %ii = add nsw i32 %aa, %a36 %ll = add i32 %b, 4537 %exitcond2 = icmp sge i32 %ii, %b38 br i1 %exitcond2, label %G, label %exit, !prof !1739 40exit:41 ret i32 042}43 44!llvm.module.flags = !{!0}45!0 = !{i32 1, !"ProfileSummary", !1}46!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}47!2 = !{!"ProfileFormat", !"InstrProf"}48!3 = !{!"TotalCount", i64 10000}49!4 = !{!"MaxCount", i64 10}50!5 = !{!"MaxInternalCount", i64 1}51!6 = !{!"MaxFunctionCount", i64 1000}52!7 = !{!"NumCounts", i64 3}53!8 = !{!"NumFunctions", i64 3}54!9 = !{!"DetailedSummary", !10}55!10 = !{!11, !12, !13}56!11 = !{i32 10000, i64 100, i32 1}57!12 = !{i32 999000, i64 100, i32 1}58!13 = !{i32 999999, i64 1, i32 2}59!14 = !{!"function_entry_count", i64 1000}60!15 = !{!"branch_weights", i32 4, i32 1}61!16 = !{!"branch_weights", i32 128, i32 1}62!17 = !{!"branch_weights", i32 1, i32 1}63