summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorEhud Katz <ehudkatz@gmail.com>2019-11-03 17:28:54 +0200
committerEhud Katz <ehudkatz@gmail.com>2019-11-22 21:17:11 +0200
commite62555c129d535d524354351791c5474c9929582 (patch)
tree45c2b1575ccad7f48ea02f19be6b076a00611255 /llvm/lib/Support/APFloat.cpp
parent718d68e6ca874fcb8a720790c899fa311f15675a (diff)
downloadbcm5719-llvm-e62555c129d535d524354351791c5474c9929582.tar.gz
bcm5719-llvm-e62555c129d535d524354351791c5474c9929582.zip
[APFloat] Fix subtraction of subnormal numbers
Fix incorrect determination of the bigger number out of the two subtracted, while subnormal numbers are involved. Fixes PR44010. Differential Revision: https://reviews.llvm.org/D69772
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r--llvm/lib/Support/APFloat.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index b79baf1834a..c7500acaa72 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -1484,22 +1484,19 @@ lostFraction IEEEFloat::addOrSubtractSignificand(const IEEEFloat &rhs,
/* Subtraction is more subtle than one might naively expect. */
if (subtract) {
IEEEFloat temp_rhs(rhs);
- bool reverse;
- if (bits == 0) {
- reverse = compareAbsoluteValue(temp_rhs) == cmpLessThan;
+ if (bits == 0)
lost_fraction = lfExactlyZero;
- } else if (bits > 0) {
+ else if (bits > 0) {
lost_fraction = temp_rhs.shiftSignificandRight(bits - 1);
shiftSignificandLeft(1);
- reverse = false;
} else {
lost_fraction = shiftSignificandRight(-bits - 1);
temp_rhs.shiftSignificandLeft(1);
- reverse = true;
}
- if (reverse) {
+ // Should we reverse the subtraction.
+ if (compareAbsoluteValue(temp_rhs) == cmpLessThan) {
carry = temp_rhs.subtractSignificand
(*this, lost_fraction != lfExactlyZero);
copySignificand(temp_rhs);
OpenPOWER on IntegriCloud