summaryrefslogtreecommitdiff
path: root/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-09-26 14:06:58 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-09-26 14:06:58 +0000
commit3e7735fe1c9e8f1cbad1bac02fbb998017fd0cbb (patch)
tree438b0956b900cfe4122320661082c65a9ddf82d4 /lib/Support/APFloat.cpp
parent50b7d70707960155ad28ff23d7622009b7b97eb3 (diff)
downloadllvm-3e7735fe1c9e8f1cbad1bac02fbb998017fd0cbb.tar.gz
llvm-3e7735fe1c9e8f1cbad1bac02fbb998017fd0cbb.tar.bz2
llvm-3e7735fe1c9e8f1cbad1bac02fbb998017fd0cbb.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r--lib/Support/APFloat.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index f143e6d0ad..d07a3c9e7f 100644
--- a/lib/Support/APFloat.cpp
+++ b/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