[llvm-commits] Fix Bug 13574: Add more double float shrinking optimizations

Weiming Zhao weimingz at codeaurora.org
Wed Aug 15 13:37:46 PDT 2012


Hi Steve,

 

Yes, it transforms (float)func((double) val) to funcf(v), which saves 2
conversions and possibly cheaper math  function. 

 

GCC O1 does the same transformation. For LLVM, we can guard the
transformations by flags like fast-math or a separate flag.

Furthermore, such transformation can be disabled by default. So it also
solves the performance issue of double/single FP on some platforms.

 

Thanks,

Weiming

 

From: Stephen Canon [mailto:scanon at apple.com] 
Sent: Wednesday, August 15, 2012 11:54 AM
To: Weiming Zhao
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] Fix Bug 13574: Add more double float shrinking
optimizations

 

Do I understand correctly that this optimization would transform
cos((double)floatval) --> (double)cosf(floatval)?  That's not a acceptable
transformation, numerically.

 

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.

 

- Steve

 

On Aug 15, 2012, at 2:33 PM, Weiming Zhao <weimingz at codeaurora.org> wrote:





Hi,

 

This patch fixes  <http://llvm.org/bugs/show_bug.cgi?id=13574>
http://llvm.org/bugs/show_bug.cgi?id=13574

 

Current LLVM only supports 5 double->float shrinking optimizations
(floor->floorf, ceil->ceilf,round->roundf, rint->rintf() and
nearbyint->nearbyintf).

 

This patch adds more math functions, for example, pow->powf, sin->sinf,
cos->cosf, etc.

 

In this patch:

1.     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.

For this change, I have to hoist the definition of UnaryDoubleFPOpt ahead of
CosOpt.

 

2.       Since some functions are not available on Windows, I updated
TargetLibraryInfo to mark them as unavailable.

 

3.       A unit test case is updated to test this patch.

 

Please help to review them.

 

Thanks,

Weiming

<0001-Bug-13574-More-double-float-shrinking-optimizations-f.patch>__________
_____________________________________
llvm-commits mailing list
 <mailto:llvm-commits at cs.uiuc.edu> llvm-commits at cs.uiuc.edu
 <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120815/35f9c5f5/attachment.html>


More information about the llvm-commits mailing list