This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: BlockPlacement: Minor probability changes.
ClosedPublic

Authored by iteratee on Mar 31 2017, 5:40 PM.

Details

Reviewers
davidxl
Summary

Qin may be large, and Succ may be more frequent than BB. Take these both into
account when deciding if tail-duplication is profitable.

Diff Detail

Event Timeline

iteratee created this revision.Mar 31 2017, 5:40 PM
davidxl added inline comments.Apr 1 2017, 12:09 PM
lib/CodeGen/MachineBlockPlacement.cpp
800–801

this layout or BB, Succ, D Dom, C+Succ ?

801–803

Move this line up by two lines.

802

should it be

min (Qout + F + Qin * U, Qout + Qin + F * U)?

iteratee updated this revision to Diff 93926.Apr 3 2017, 12:45 PM
iteratee marked 2 inline comments as done.

Update comments in response to review.

lib/CodeGen/MachineBlockPlacement.cpp
802

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.

iteratee updated this revision to Diff 94124.Apr 4 2017, 2:36 PM

Minor adjustment to another affected test.

davidxl added inline comments.Apr 10 2017, 11:10 AM
lib/CodeGen/MachineBlockPlacement.cpp
802

Is it always the same?

iteratee added inline comments.Apr 10 2017, 1:14 PM
lib/CodeGen/MachineBlockPlacement.cpp
802

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)
davidxl accepted this revision.Apr 10 2017, 1:46 PM

lgtm

This revision is now accepted and ready to land.Apr 10 2017, 1:46 PM
iteratee closed this revision.May 2 2017, 4:35 PM

Committed as rL299891