<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 12/9/13 2:13 PM, Raoux, Thomas F
wrote:<br>
</div>
<blockquote
cite="mid:0BE061694B9B9245AA01A260008816C46B82C38E@ORSMSX110.amr.corp.intel.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<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;}
/* 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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.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]-->
<div class="WordSection1">
<p class="MsoNormal">Constant propagation pass generates
constant expression when undef is used in float instructions
instead of propagating the undef value.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">; Function Attrs: nounwind<o:p></o:p></p>
<p class="MsoNormal">define float @_Z1fv() #0 {<o:p></o:p></p>
<p class="MsoNormal">entry:<o:p></o:p></p>
<p class="MsoNormal"> %add = fadd fast float undef,
2.000000e+00<o:p></o:p></p>
<p class="MsoNormal"> ret float %add<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Becomes:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">; Function Attrs: nounwind<o:p></o:p></p>
<p class="MsoNormal">define float @_Z1fv() #0 {<o:p></o:p></p>
<p class="MsoNormal">entry:<o:p></o:p></p>
<p class="MsoNormal"> ret float fadd (float undef, float
2.000000e+00)<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is it safe to transform “%add = fadd fast
float undef, 2.000000e+00” to “undef”? Is there a reason why
constant propagation pass doesn’t do this transformation?<o:p></o:p></p>
</div>
</blockquote>
I'm not totally sure this is safe. Not saying it isn't, but the
wording around undef and bit patterns in the language spec is
concerning me. Could there be a case where some bit of the result
is known given only one constant argument? I'm not familiar enough
with the floating point semantics of LLVM's IR, but suspect there
might be such a case. A few cases worth thinking about: undef +
max_float, undef + NAN (signaling or non-signalling). If someone
more familiar with floating point knows better, please feel free to
chime in. <br>
<br>
On the other hand, the following transformation is definitely safe:<br>
<p class="MsoNormal">define float @_Z1fv() #0 {<o:p></o:p></p>
<p class="MsoNormal">entry:<o:p></o:p></p>
<p class="MsoNormal"> ret 2.000000e+00<o:p></o:p></p>
}<br>
(undef could be zero, thus result of the add is the second argument)<br>
<br>
If we don't apply that transform, we probably should. (Well,
assuming there's not some normalization/rounding trap here. I
don't *think* there is, but I'm not totally sure.)<br>
<br>
Yours,<br>
Philip<br>
<br>
<br>
</body>
</html>