diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-09-26 14:06:58 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-09-26 14:06:58 +0000 |
commit | c38fab201364abdcf3ea653d68cb278d32c19fa1 (patch) | |
tree | d74ce7dba543efda8eb8f8a45581aaa9a70aa8f7 /llvm/lib | |
parent | cd3a11f72576b88578f5615ab3d24919b6e60aae (diff) | |
download | bcm5719-llvm-c38fab201364abdcf3ea653d68cb278d32c19fa1.tar.gz bcm5719-llvm-c38fab201364abdcf3ea653d68cb278d32c19fa1.zip |
APFloat::roundToIntegral: Special values don't keep the exponent value up to date, don't rely on it.
Add a couple of unit tests for special floats. Fixes 13929, found by MemorySanitizer.
llvm-svn: 164698
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index f143e6d0ade..d07a3c9e7f3 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -1775,7 +1775,7 @@ APFloat::opStatus APFloat::roundToIntegral(roundingMode rounding_mode) { // If the exponent is large enough, we know that this value is already // integral, and the arithmetic below would potentially cause it to saturate // to +/-Inf. Bail out early instead. - if (exponent+1 >= (int)semanticsPrecision(*semantics)) + if (category == fcNormal && exponent+1 >= (int)semanticsPrecision(*semantics)) return opOK; // The algorithm here is quite simple: we add 2^(p-1), where p is the |