<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:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@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;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* 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-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.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 style='margin-bottom:12.0pt'><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>Hello,<br><br>I worked on an LLVM patch to optimize mathematical library calls and would like to submit it to your review.<br><br>A. Background:<br>In C89, most of the mathematical accept only the type "double" for the floating-point arguments. <br>Later on, in C99, this limitation was fixed by introducing new sets of functions with "f" suffixes that accept "float" arguments.   Our experiments show that, on ARM platform, the "float" type versions are significantly faster than their double precision counterparts. For example, "float sinf(float)" is 1.87 times faster than "double sin(double)".  <br> <br>However, this new set of functions are not always exploited by programmers. For example, a programmer may write:<br>void foo(float y)<br>  float x = sin(y);<br>  ...<br>}<br>instead of writing:<br>void foo(float y)<br>  float x = sinf(y);<br>  ...<br>}<br><br>B. This optimization:<br>This optimization looks for missed opportunities, in which a lighter weighted function could be used without losing precision. <br>For legitimation, the conversion is performed only if:<br>1) the arguments of the call are all defined by FP extension instructions. For example, in the first function, for "sin(y)", "y" is implicitly extended from "float" to "double"<br><br>2) the return value of the call is only used by a FP truncation instruction. For example, in the first function, the return value of "sin(y)" is only used by a truncation from "double" to "float" and then assigned to variable "x".<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:black'>Hence, this transformation will not result in precision loss.<br><br>C. Patch details (libcall_fp_version_opt.diff):<br>1) lib/Transforms/Scalar/SimplifyLibCalls.cpp:  we added a new pass, called "ReplaceLibCallVersions", for this optimization. This pass inherits from the existing SimplifyLibCalls pass and the concrete optimizing class also inherits from the existing LibCallOptimization class. The reason we do not merge our codes into the existing SimpliyLibCalls pass is that both pass will optimize for some common lib calls (e.g. pow()). <br><br>2) lib/Target/ARM/ARMTargetMachine.cpp: so far, we only tested and verified this pass on ARM,  so we only invoke it for ARM, which is the same way as  Global-Merge pass does.  Please feel free to let us know if you want to make it available for all architectures. <br><br>3) test/CodeGen/ARM/libcallconv.ll: test cases for this optimization <br><br>D. Failure report<br>Failure report from running llvm/test and projects/test-suite on ARM.<br>I noted failures running llvm/test (svn rev 143352) and projects/test-suite (svn rev 142659) .<br><br>Thank you,<br>Weiming Zhao<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p></div></body></html>