<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sean Silva [mailto:chisophugis@gmail.com]
<br>
<b>Sent:</b> Thursday, August 27, 2015 5:39 PM<br>
<b>To:</b> reviews+D12341+public+5f663c68720e9677@reviews.llvm.org; Smith, Kevin B<br>
<b>Cc:</b> Sanjay Patel; Chandler Carruth; Krzysztof Parzyszek; Hal Finkel; Bob Wilson; kubastaszak@gmail.com; llvm-commits<br>
<b>Subject:</b> Re: [PATCH] D12341: add llvm.unpredictable intrinsic and lower it to metadata<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Thu, Aug 27, 2015 at 3:13 PM, Kevin B. Smith via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">kbsmith1 added a comment.<br>
<br>
No, I am not suggesting you have more history.  I am suggesting that you only have a single number that represents the percentage of time that the direction is mispredicted.  It would make a lot of sense for it to be a simple 0-100 value, and would represent
 the percentage of mispredictions. Anything else takes more space, and is much too closely tied to the branch predictor.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#4F81BD">I have seen 2 independent bug reports recently where the simple annotation to the compiler "assume that this is completely unpredictable" would have been the solution. Some pieces of code very closely approximate
 this, especially in decompression algorithms where by definition if the encoder is doing its job then the pattern cannot be guessed. Other data-driven branches can approximate this behavior as well.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#4F81BD"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#4F81BD">This is more a declaration about the actual pattern of the branch. A number indicating the percentage of mispredictions (or any empirically collected number) is not a generalization of this annotation.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#4F81BD"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#4F81BD">-- Sean Silva<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">Sean – Yes, I agree this is about an inherent property of the branch, or condition. But percentage of mispredictions could easily be used<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">to convey that information.  Simply set the value to 100 to say that 100% of the time the branch/condition is mispredicted, and consider that<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">the declaration about the actual pattern, rather than an actual number.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">To some extent this mimics __builtin_expect, which allows a specification of the probability of a condition having a certain value, but where in actual usage,
 the user’s usage is likely to be always 0 or always 100 for hinting purposes.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">This allows a single type of annotation to be used for both the user specified property, and also for HW feedback.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D">Kevin Smith<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
ABAB can be perfectly predicted often, AABB can be perfectly predicted often. The number of transitions from true to false or vice-versa has a poor<br>
correlation to branch predictability, just as the branch probability has a poor correlation to branch predictability.<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
<br>
<a href="http://reviews.llvm.org/D12341" target="_blank">http://reviews.llvm.org/D12341</a><br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>