<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 07/15/2015 05:01 AM, <a class="moz-txt-link-abbreviated" href="mailto:ed@modk.it">ed@modk.it</a>
wrote:<br>
</div>
<blockquote
cite="mid:CAE1NinDgtThiKkH4vXcogcQhcEDJX3DhUpeVzQUdhvzUk5QYfw@mail.gmail.com"
type="cite">
<div dir="ltr">Hi All,
<div><br>
</div>
<div>Clang lacks support for the -fsingle-precision-constant
flag. Are there specific reasons for this or is it just
waiting to be implemented?</div>
<div><br>
</div>
<div>This flag is especially important in the embedded world.
From <a moz-do-not-send="true"
href="https://urldefense.proofpoint.com/v2/url?u=http-3A__processors.wiki.ti.com_index.php_Floating-5FPoint-5FOptimization-23float-5Fvs.-5Fdouble-5Fvs.-5Flong-5Fdouble&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=SziAjiSP8N_rg2b1QO6yqe6DPgAQ-gYuJ_OnsXjdwQo&s=q4wtrH7nx201oaODowm17ir7UAGlp2RfLweJDCQuXLA&e=">http://processors.wiki.ti.com/index.php/Floating_Point_Optimization#float_vs._double_vs._long_double</a>:</div>
<div><br>
</div>
<div><span
style="color:rgb(37,37,37);line-height:22.3999996185303px"><font
face="arial, helvetica, sans-serif"><i>Once all of your
data is defined as float, there are still cases where
you may unknowingly cause the compiler to generate
double precision operations. The most common issue is
when floating point literals such as 3.14159 are used.
In C these literals are of type double, and if they are
used in an expression consisting of single precision
operands, the operations will be promoted to double
precision. The proper way to specify a single precision
literal is to use an 'f' suffix, 3.14159f.</i></font></span><br>
</div>
<div><span
style="color:rgb(37,37,37);line-height:22.3999996185303px"><font
face="arial, helvetica, sans-serif"><i><br>
</i></font></span></div>
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px">While defining
literals without the 'f' suffix may point to performance
issues, in our case the target crashes when the 'f' is
omitted. This is an end user programmable system where we
can't expect users to add the 'f'. I don't fully
understand why this occurs (this is a bare metal system
where user code is run by a quasi-OS which is maintained
by a different team and itself is compiled with a
different compiler so it's hard to track down) we remedied
this with the -fsingle-precision-constant in gcc. Now
that we're moving to clang/llvm we need a solution and
expecting the user to add 'f' is not going to work. <br>
</span></font></div>
</div>
</blockquote>
<font color="#252525"><font face="arial, helvetica, sans-serif">Another
approach might be to add a dedicated warning (off by default)
which warns or errors on these cases. It also seems like a case
where a clang-tidy rewrite rule</font></font> could help. <br>
<blockquote
cite="mid:CAE1NinDgtThiKkH4vXcogcQhcEDJX3DhUpeVzQUdhvzUk5QYfw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px"><br>
</span></font></div>
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px">Any thoughts?</span></font></div>
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px"><br>
</span></font></div>
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px">Thanks,</span></font></div>
<div><font color="#252525" face="arial, helvetica, sans-serif"><span
style="line-height:22.3999996185303px">Ed</span></font></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>