mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
Fix APFloat mod sign
fmod specification requires the sign of the remainder is the same as numerator in case remainder is zero. Reviewers: gottesmm, scanon, arsenm, davide, craig.topper Reviewed By: scanon Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D39225 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317081 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1743,6 +1743,7 @@ IEEEFloat::opStatus IEEEFloat::remainder(const IEEEFloat &rhs) {
|
||||
IEEEFloat::opStatus IEEEFloat::mod(const IEEEFloat &rhs) {
|
||||
opStatus fs;
|
||||
fs = modSpecials(rhs);
|
||||
unsigned int origSign = sign;
|
||||
|
||||
while (isFiniteNonZero() && rhs.isFiniteNonZero() &&
|
||||
compareAbsoluteValue(rhs) != cmpLessThan) {
|
||||
@@ -1754,6 +1755,8 @@ IEEEFloat::opStatus IEEEFloat::mod(const IEEEFloat &rhs) {
|
||||
fs = subtract(V, rmNearestTiesToEven);
|
||||
assert(fs==opOK);
|
||||
}
|
||||
if (isZero())
|
||||
sign = origSign; // fmod requires this
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user