<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=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@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>Reposting bug report here, any chance that it can get
reviewed?<o:p></o:p></p>
<p class=MsoNormal>Patch that adds a boolean where a backend can specify
whether to disable<o:p></o:p></p>
<p class=MsoNormal>certain optimizations because jumps are expensive.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>The selection dag builder has an ‘optimization’
added into the visitBr function<o:p></o:p></p>
<p class=MsoNormal>which makes assumptions that are not valid on all
architectures. The problem is<o:p></o:p></p>
<p class=MsoNormal>this.<o:p></o:p></p>
<p class=MsoNormal>The following function<o:p></o:p></p>
<p class=MsoNormal>kernel void cf_test(global int* a, int b, int c, int e)<o:p></o:p></p>
<p class=MsoNormal>{<o:p></o:p></p>
<p class=MsoNormal> int d = 0;<o:p></o:p></p>
<p class=MsoNormal> if (!b && c < e) {<o:p></o:p></p>
<p class=MsoNormal> d = a + b;<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> *a = d;<o:p></o:p></p>
<p class=MsoNormal>}<o:p></o:p></p>
<p class=MsoNormal>Is transformed into something equivalent to this:<o:p></o:p></p>
<p class=MsoNormal>Kernel void cf_test(global int* a, int b, int c, int e)<o:p></o:p></p>
<p class=MsoNormal>{<o:p></o:p></p>
<p class=MsoNormal> Int d;<o:p></o:p></p>
<p class=MsoNormal> If (b) {<o:p></o:p></p>
<p class=MsoNormal> d = 0;<o:p></o:p></p>
<p class=MsoNormal> } else {<o:p></o:p></p>
<p class=MsoNormal> if (c < e) {<o:p></o:p></p>
<p class=MsoNormal> d = a + b;<o:p></o:p></p>
<p class=MsoNormal> } else {<o:p></o:p></p>
<p class=MsoNormal> d = 0;<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> }<o:p></o:p></p>
<p class=MsoNormal> *a = d;<o:p></o:p></p>
<p class=MsoNormal>}<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>by the visitBr code found in
SelectionDAGBuilder::visitBr():1188.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>However, if jumps are expensive or jumps are not supported
and high level flow<o:p></o:p></p>
<p class=MsoNormal>control needs to be reconstructed. This is extremely
inefficient. For example<o:p></o:p></p>
<p class=MsoNormal>on AMD GPU’s, a single flow control instruction can
take 40 cycles to execute,<o:p></o:p></p>
<p class=MsoNormal>but an bit instruction, can be executed every cycle. So
obviously the<o:p></o:p></p>
<p class=MsoNormal>assumptions made by this block of code are inefficient on
AMD hardware. <o:p></o:p></p>
<p class=MsoNormal>Increasing control flow has a direct impact on performance
and removing the<o:p></o:p></p>
<p class=MsoNormal>extra ‘and’ or ‘or’ in order to
short circuit the conditional evaluation does<o:p></o:p></p>
<p class=MsoNormal>not work for our target.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>So in order to make this type of instruction rely more on
target specific<o:p></o:p></p>
<p class=MsoNormal>information. I’ve added a new Boolean to the
TargetLoweringInfo class called<o:p></o:p></p>
<p class=MsoNormal>JumpIsExpensive along with accessor functions.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Please review the patch and apply if acceptable.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>