diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-03-30 15:42:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-03-30 15:42:27 +0000 |
commit | 2746000f4fa54e6ad00cf96910ea5772803624ed (patch) | |
tree | bd6513967e2f459833124c1834762d983bf7b3b0 /include | |
parent | d01f2633b9aab6281c936da04226b46a0dde7ba9 (diff) | |
download | external_llvm-2746000f4fa54e6ad00cf96910ea5772803624ed.zip external_llvm-2746000f4fa54e6ad00cf96910ea5772803624ed.tar.gz external_llvm-2746000f4fa54e6ad00cf96910ea5772803624ed.tar.bz2 |
Add APFloat::getExactInverse.
The idea is, that if an ieee 754 float is divided by a power of two, we can
turn the division into a cheaper multiplication. This function sees if we can
get an exact multiplicative inverse for a divisor and returns it if possible.
This is the hard part of PR9587.
I tested many inputs against llvm-gcc's frotend implementation of this
optimization and didn't find any difference. However, floating point is the
land of weird edge cases, so any review would be appreciated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/APFloat.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index ca4138b..21b8c86 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -353,6 +353,10 @@ namespace llvm { unsigned FormatPrecision = 0, unsigned FormatMaxPadding = 3) const; + /// getExactInverse - If this value has an exact multiplicative inverse, + /// store it in inv and return true. + bool getExactInverse(APFloat *inv) const; + private: /* Trivial queries. */ |