<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://321/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Do I understand correctly that this optimization would transform cos((double)floatval) --> (double)cosf(floatval)?  That's not a acceptable transformation, numerically.</div><div><br></div><div>One should also consider that there are a number of platforms supported by LLVM (not naming names) on which the float variants of libm functions are significantly *slower* than the double-precision variants.</div><div><br></div><div>- Steve</div><br><div><div>On Aug 15, 2012, at 2:33 PM, Weiming Zhao <<a href="mailto:weimingz@codeaurora.org">weimingz@codeaurora.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Hi,<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">This patch fixes<span class="Apple-converted-space"> </span><a href="http://llvm.org/bugs/show_bug.cgi?id=13574" style="color: purple; text-decoration: underline; ">http://llvm.org/bugs/show_bug.cgi?id=13574</a><o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; ">Current LLVM only supports 5 double->float shrinking optimizations (floor->floorf, ceil->ceilf,round->roundf, rint->rintf() and nearbyint->nearbyintf).<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; ">This patch adds more math functions, for example, pow->powf, sin->sinf, cos->cosf, etc.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; ">In this patch:<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -0.25in; "><span style="font-size: 9pt; font-family: Arial, sans-serif; "><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman'; ">    <span class="Apple-converted-space"> </span></span></span></span><span style="font-size: 9pt; font-family: Arial, sans-serif; ">Since cos(), pow() and exp2() already have their own optimizers: CosPot, PowOpt and Exp2Opt, respectively, I let them inherit from UnaryDoubleFPOpt and in their CallOptimizer(), I let them to call the base class’s CallOptimizer() first.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; ">For this change, I have to hoist the definition of UnaryDoubleFPOpt ahead of CosOpt.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 9pt; font-family: Arial, sans-serif; "> </span></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -0.25in; "><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman'; ">      <span class="Apple-converted-space"> </span></span></span>Since some functions are not available on Windows, I updated TargetLibraryInfo to mark them as unavailable.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -0.25in; "><span>3.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman'; ">      <span class="Apple-converted-space"> </span></span></span>A unit test case is updated to test this patch.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Please help to review them.<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Thanks,<o:p></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Weiming<o:p></o:p></div></div><span><0001-Bug-13574-More-double-float-shrinking-optimizations-f.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" style="color: purple; text-decoration: underline; ">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></blockquote></div><br></body></html>