Commit Graph

126 Commits

Author SHA1 Message Date
Eli Friedman 31f0116173 Add back a line I deleted by accident in r145141. Fixes uninitialized variable warnings and runtime failures.
llvm-svn: 145256
2011-11-28 18:50:37 +00:00
Eli Friedman a84ad7d0d0 Fix APFloat::convert so that it handles narrowing conversions correctly; it
was returning incorrect values in rare cases, and incorrectly marking
exact conversions as inexact in some more common cases. Fixes PR11406, and a
missed optimization in test/CodeGen/X86/fp-stack-O0.ll.

llvm-svn: 145141
2011-11-26 03:38:02 +00:00
Eli Friedman d433042388 Fix APFloat::getSmallestNormalized so the shift doesn't depend on undefined behavior. Patch from Ahmed Charles.
llvm-svn: 141818
2011-10-12 21:56:19 +00:00
Eli Friedman c53220134a Fix APFloat::getLargest so that it actually returns the correct value. Found by accident while reviewing a patch to nearby code.
llvm-svn: 141816
2011-10-12 21:51:36 +00:00
Eli Friedman 195464184e Fix APInt::operator*= so that it computes the correct result for large integers where there is unsigned overflow. Fix APFloat::toString so that it doesn't depend on the incorrect behavior in common cases (and computes the correct result in some rare cases). Fixes PR11086.
llvm-svn: 141441
2011-10-07 23:40:49 +00:00
Nick Lewycky f66daac2f5 Fix typo in comments.
llvm-svn: 141032
2011-10-03 21:30:08 +00:00
Duncan Sands a41634e307 Silence a bunch (but not all) "variable written but not read" warnings
when building with assertions disabled.

llvm-svn: 137460
2011-08-12 14:54:45 +00:00
Jeffrey Yasskin 7a16288157 Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity
errors like the one corrected by r135261.  Migrate all LLVM callers of the old
constructor to the new one.

llvm-svn: 135431
2011-07-18 21:45:40 +00:00
Chandler Carruth 1bf4a30d4d Explicitly cast the second argument to unsigned in order to select the
desired overload.

This is a bit of a hackish workaround to fix the compile after r135259.
Let me know if there is a better approach.

llvm-svn: 135261
2011-07-15 07:31:10 +00:00
Jeffrey Yasskin 03b81a2eb4 Add an APFloat::convertToInt(APSInt) function that automatically manages the
memory for the result.

llvm-svn: 135259
2011-07-15 07:04:56 +00:00
Chris Lattner 0ab5e2cded Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Benjamin Kramer af0ed953c5 Avoid turning a floating point division with a constant power of two into a denormal multiplication.
Some platforms may treat denormals as zero, on other platforms multiplication
with a subnormal is slower than dividing by a normal.

llvm-svn: 128555
2011-03-30 17:02:54 +00:00
Benjamin Kramer 03fd672609 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.

llvm-svn: 128545
2011-03-30 15:42:27 +00:00
Bill Wendling a50db6544f Initialize the only-used-with-PPC-double-double parts of the APFloat class. This
makes valgrind stop complaining about uninitialized variables being read when it
accesses a bitfield (category) that shares its bits with these variables.

llvm-svn: 127871
2011-03-18 09:09:44 +00:00
Nadav Rotem 7cc6d12ad0 Enhance constant folding of bitcast operations on vectors of floats.
Add getAllOnesValue of FP numbers to Constants and APFloat.
Add more tests.

llvm-svn: 125776
2011-02-17 21:22:27 +00:00
Ted Kremenek 3c4408ceb6 Null initialize a few variables flagged by
clang's -Wuninitialized-experimental warning.
While these don't look like real bugs, clang's
-Wuninitialized-experimental analysis is stricter
than GCC's, and these fixes have the benefit
of being general nice cleanups.

llvm-svn: 124073
2011-01-23 17:05:06 +00:00
Abramo Bagnara a41d7aebee Fixed parsing of hex floats.
llvm-svn: 122963
2011-01-06 16:55:14 +00:00
Jay Foad 583abbc4df PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Jay Foad 3447fb01c0 PR5207: change APInt::doubleToBits() and APInt::floatToBits() to be
static methods that return a new APInt.

llvm-svn: 120261
2010-11-28 21:04:48 +00:00
Dale Johannesen 370c77c064 Do not assert when reading an exponent out of range.
llvm-svn: 111534
2010-08-19 17:58:35 +00:00
Benjamin Kramer 92d8998348 Don't pass StringRef by reference.
llvm-svn: 108366
2010-07-14 22:38:02 +00:00
Dan Gohman b452d4e9e4 Fix minor style issues.
llvm-svn: 99414
2010-03-24 19:38:02 +00:00
Chris Lattner 4c1e4db3ff make APFloat::toString be const.
llvm-svn: 97883
2010-03-06 19:20:13 +00:00
John McCall c6dbe30e88 Don't potentially read past the end of the fill data when making a NaN from
an APInt.

llvm-svn: 97467
2010-03-01 18:38:45 +00:00
John McCall c12b133d00 Properly clear all the extra bits in a significand when making a NaN from an
APInt.  Be certain to set the integer bit in an x87 extended-precision
significand so that we don't accidentally make a pseudo-NaN.

llvm-svn: 97382
2010-02-28 12:49:50 +00:00
John McCall dcb9a7ad3d Teach APFloat how to create both QNaNs and SNaNs and with arbitrary-width
payloads.  APFloat's internal folding routines always make QNaNs now,
instead of sometimes making QNaNs and sometimes SNaNs depending on the
type.

llvm-svn: 97364
2010-02-28 02:51:25 +00:00
John McCall b42cc681ba Make APFloat's string-parsing routines a bit safer against very large exponents.
llvm-svn: 97278
2010-02-26 22:20:41 +00:00
John McCall dd5044ac55 Implement support for converting to string at "natural precision", and fix some
major bugs in long-precision conversion.

llvm-svn: 92150
2009-12-24 23:18:09 +00:00
John McCall e6212ace38 Substantially optimize APFloat::toString() by doing a single large divide to
cut the significand down to the desired precision *before* entering the
core divmod loop.  Makes the overall algorithm logarithmic in the exponent.

There's still a lot of room for improvement here, but this gets the
performance back down to acceptable-for-diagnostics levels, even for
long doubles.
negligible, even on long doubles.

llvm-svn: 92130
2009-12-24 12:16:56 +00:00
John McCall 29b5c284ae Add accessors for the largest-magnitude, smallest-magnitude, and
smallest-normalized-magnitude values in a given FP semantics.
Provide an APFloat-to-string conversion which I am quite ready to admit could
be much more efficient.

llvm-svn: 92126
2009-12-24 08:56:26 +00:00
Evan Cheng deab9dee12 Remove getIEEEFloatParts and getIEEEDoubleParts. They are not needed.
llvm-svn: 85358
2009-10-28 01:08:17 +00:00
Evan Cheng 67c902147e Add new APFloat methods that return sign, exp, and mantissa of ieee float and double values.
llvm-svn: 85318
2009-10-27 21:35:42 +00:00
Dale Johannesen 0d670b5b92 Commit fixes for half precision I noted in review, so
they don't get lost; I don't think the originator has
write access.

llvm-svn: 84928
2009-10-23 04:02:51 +00:00
Chris Lattner 4794b2b27b Add half precision floating point support (float16) to APFloat,
patch by Peter Johnson! (PR5195)

llvm-svn: 84239
2009-10-16 02:13:51 +00:00
Chris Lattner 688f991b38 wrap long lines.
llvm-svn: 82715
2009-09-24 21:44:20 +00:00
Chris Lattner ac6271e3f4 add a version of the APFloat constructor that initializes to 0.0
llvm-svn: 82110
2009-09-17 01:08:43 +00:00
Anton Korobeynikov 876955cbb0 Fix typo.
llvm-svn: 79688
2009-08-21 23:09:47 +00:00
Anton Korobeynikov 13e8c7ef20 Implement APInt <-> APFloat conversion for IEEE 128-bit floats.
This fixes PR2555

llvm-svn: 79677
2009-08-21 22:10:30 +00:00
Erick Tryzelaar da666c801c Add support for including '+' in APFloat strings, more asserts,
and many new unit tests.

llvm-svn: 79574
2009-08-20 23:30:43 +00:00
Daniel Dunbar bf5998edfb Fix two APFloat bugs in converting hexadecimal constants.
llvm-svn: 79540
2009-08-20 17:12:33 +00:00
Erick Tryzelaar a9680df669 Fix an uninitialized value warning in APFloat.
llvm-svn: 79353
2009-08-18 18:20:37 +00:00
Erick Tryzelaar 19f63b2e4d Modify APFloat to take a StringRef instead of a c string.
This also adds unit tests to APFloat that mainly tests the
string handling of APFloat, but not much else of it's api.

llvm-svn: 79210
2009-08-16 23:36:19 +00:00
Torok Edwin fbcc663cbf llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").

llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Torok Edwin 56d0659726 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.

llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Mike Stump 799bf5855e Add support for letting the client choose different flavors of NaNs. Testcase to be
added in clang.

llvm-svn: 72606
2009-05-30 03:49:43 +00:00
Mike Stump 889285d467 Fix whitespacing (space after switch).
llvm-svn: 71738
2009-05-13 23:23:20 +00:00
Dale Johannesen 93eefa0043 Fix internal representation of fp80 to be the
same as a normal i80 {low64, high16} rather
than its own {high64, low16}.  A depressing number
of places know about this; I think I got them all.
Bitcode readers and writers convert back to the old
form to avoid breaking compatibility.

llvm-svn: 67562
2009-03-23 21:16:53 +00:00
Chris Lattner b858c0eba0 just initialize the first element, we don't need to set the rest to zeros.
llvm-svn: 66850
2009-03-13 00:24:01 +00:00
Chris Lattner 0bf186906b Eliminate a 9640 byte static mutable initialized data item by moving it
to the stack.  This shrinks all llvm tools by 9k, and improves reentrancy.

llvm-svn: 66847
2009-03-13 00:03:51 +00:00
Chris Lattner 9170209603 static functions don't need an anonymous namespace.
llvm-svn: 66845
2009-03-12 23:59:55 +00:00