[llvm-dev] Getting consistent block frequency information
Joshua Cranmer via llvm-dev
llvm-dev at lists.llvm.org
Tue Mar 13 14:24:03 PDT 2018
Hi,
I've been trying to get frequency information for basic blocks and edges
between basic blocks using MachineBlockFrequencyInfo and
MachineBranchProbabilityInfo. Unfortunately, the results returned don't
seem to give high consistency.
If I have code like the following:
define i32 @foo(i32 %i, i32* %addr) {
entry:
%tobool = icmp ne i32 %i, 0
br i1 %tobool, label %if.end, label %if.then
if.then:
%add = add i32 %i, 1
store i32 %add, i32* %addr
br label %return
if.end:
%mul = mul i32 %i, 2
store i32 %mul, i32* %addr
br label %return
return:
%ret = load i32, i32* %addr
ret i32 %ret
}
The branch probability information suggests that the edge from
entry->if.then and the edge from entry->if.end are executed in a 5:3
ratio. The resulting block frequency information, when queried in
integer form, reports that entry and return has an integer count of 21,
if.then as 13, and if.end as 8. I get different results if I do the
obvious thing of getting the branch probability and multiplying it by
the block frequency information to derive edge frequency; for example,
in this case, multiplying 21 by 3/8 returns 7 instead of 8 for the edge
from entry to if.end. Choosing a particular order to generate the block
orders (to match up with the derivation of block mass estimates) doesn't
appear to yield the correct results.
Is there any way to get more accurate results?
--
Joshua Cranmer
Thunderbird module owner
DXR coauthor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180313/df077170/attachment.html>
More information about the llvm-dev
mailing list