[PATCH] D31559: CodeGen: BlockPlacement: Minor probability changes.

Kyle Butt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 13:14:40 PDT 2017


iteratee added inline comments.


================
Comment at: lib/CodeGen/MachineBlockPlacement.cpp:801
+  // Let F = SuccFreq - Qin
+  // is Qout + max(F, Qin) * U + min(F, Qin)
   // compare P + U vs Qout + P * U + Qin.
----------------
davidxl wrote:
> iteratee wrote:
> > davidxl wrote:
> > > should it be 
> > > 
> > > min (Qout + F + Qin * U,  Qout + Qin + F * U)?
> > They work out to be the same. I think it's simpler to compute the min/max over 2 block frequencies, rather than over a total.
> Is it always the same?
We can extract the Qout terms to start:
    Qout + min(F + Qin * U, F * U + Qin)
When is
    F + Qin * U < F * U + Qin    ?
when F < Qin:
    F + Qin * U - F *U - Qin < 0
    F (1 - U) - Qin (1 - U) < 0
    F (1 - U) < Qin (1 - U)
    F < Qin        (This requires U < 1, but it's a probability)



https://reviews.llvm.org/D31559





More information about the llvm-commits mailing list