1*9880d681SAndroid Build Coastguard Worker; 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*9880d681SAndroid Build Coastguard Worker; 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*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; Test that by changing BlockFrequencyInfo we change the order in which 5*9880d681SAndroid Build Coastguard Worker; machine-sink looks for sucessor blocks. By not using BFI, both G and B 6*9880d681SAndroid Build Coastguard Worker; have the same loop depth and no instructions is sinked - B is selected but 7*9880d681SAndroid Build Coastguard Worker; can't be used as to avoid breaking a non profitable critical edge. By using 8*9880d681SAndroid Build Coastguard Worker; BFI, "mul" is sinked into the less frequent block G. 9*9880d681SAndroid Build Coastguard Workerdefine i32 @sink_freqinfo(i32 %a, i32 %b) nounwind uwtable ssp { 10*9880d681SAndroid Build Coastguard Worker; MSINK_BFI-LABEL: sink_freqinfo 11*9880d681SAndroid Build Coastguard Worker; MSINK_BFI: jl 12*9880d681SAndroid Build Coastguard Worker; MSINK_BFI-NEXT: ## BB# 13*9880d681SAndroid Build Coastguard Worker; MSINK_BFI-NEXT: imull 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker; MSINK_NOBFI-LABEL: sink_freqinfo 16*9880d681SAndroid Build Coastguard Worker; MSINK_NOBFI: imull 17*9880d681SAndroid Build Coastguard Worker; MSINK_NOBFI: jl 18*9880d681SAndroid Build Coastguard Workerentry: 19*9880d681SAndroid Build Coastguard Worker br label %B 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard WorkerB: 22*9880d681SAndroid Build Coastguard Worker %ee = phi i32 [ 0, %entry ], [ %inc, %F ] 23*9880d681SAndroid Build Coastguard Worker %xx = sub i32 %a, %ee 24*9880d681SAndroid Build Coastguard Worker %cond0 = icmp slt i32 %xx, 0 25*9880d681SAndroid Build Coastguard Worker br i1 %cond0, label %F, label %exit, !prof !0 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard WorkerF: 28*9880d681SAndroid Build Coastguard Worker %inc = add nsw i32 %xx, 2 29*9880d681SAndroid Build Coastguard Worker %aa = mul nsw i32 %b, %inc 30*9880d681SAndroid Build Coastguard Worker %exitcond = icmp slt i32 %inc, %a 31*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %B, label %G, !prof !1 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard WorkerG: 34*9880d681SAndroid Build Coastguard Worker %ii = add nsw i32 %aa, %a 35*9880d681SAndroid Build Coastguard Worker %ll = add i32 %b, 45 36*9880d681SAndroid Build Coastguard Worker %exitcond2 = icmp sge i32 %ii, %b 37*9880d681SAndroid Build Coastguard Worker br i1 %exitcond2, label %G, label %exit, !prof !2 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerexit: 40*9880d681SAndroid Build Coastguard Worker ret i32 0 41*9880d681SAndroid Build Coastguard Worker} 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Worker!0 = !{!"branch_weights", i32 4, i32 1} 44*9880d681SAndroid Build Coastguard Worker!1 = !{!"branch_weights", i32 128, i32 1} 45*9880d681SAndroid Build Coastguard Worker!2 = !{!"branch_weights", i32 1, i32 1} 46