<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,</p>
<p>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.</p>
<p>If I have code like the following:</p>
<pre>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
}
</pre>
<p>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.</p>
<p>Is there any way to get more accurate results?<br>
</p>
<pre class="moz-signature" cols="72">--
Joshua Cranmer
Thunderbird module owner
DXR coauthor</pre>
</body>
</html>