mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[APFloat] Make all arithmetic operations with NaN produce positive NaNs.
IEEE-754R 1.4 Exclusions states that IEEE-754R does not specify the interpretation of the sign of NaNs. In order to remove an irrelevant variable that most floating point implementations do not use, standardize add, sub, mul, div, mod so that operating anything with NaN always yields a positive NaN. In a later commit I am going to update the APIs for creating NaNs so that one can not even create a negative NaN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1354,6 +1354,7 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract)
|
||||
case PackCategoriesIntoKey(fcZero, fcNaN):
|
||||
case PackCategoriesIntoKey(fcNormal, fcNaN):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNaN):
|
||||
sign = false;
|
||||
category = fcNaN;
|
||||
copySignificand(rhs);
|
||||
return opOK;
|
||||
@@ -1472,11 +1473,13 @@ APFloat::multiplySpecials(const APFloat &rhs)
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
case PackCategoriesIntoKey(fcNaN, fcInfinity):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNaN):
|
||||
sign = false;
|
||||
return opOK;
|
||||
|
||||
case PackCategoriesIntoKey(fcZero, fcNaN):
|
||||
case PackCategoriesIntoKey(fcNormal, fcNaN):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNaN):
|
||||
sign = false;
|
||||
category = fcNaN;
|
||||
copySignificand(rhs);
|
||||
return opOK;
|
||||
@@ -1510,21 +1513,20 @@ APFloat::divideSpecials(const APFloat &rhs)
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
case PackCategoriesIntoKey(fcNaN, fcInfinity):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNaN):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcZero):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNormal):
|
||||
case PackCategoriesIntoKey(fcZero, fcInfinity):
|
||||
case PackCategoriesIntoKey(fcZero, fcNormal):
|
||||
return opOK;
|
||||
|
||||
case PackCategoriesIntoKey(fcZero, fcNaN):
|
||||
case PackCategoriesIntoKey(fcNormal, fcNaN):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNaN):
|
||||
category = fcNaN;
|
||||
copySignificand(rhs);
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
case PackCategoriesIntoKey(fcNaN, fcInfinity):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNaN):
|
||||
sign = false;
|
||||
case PackCategoriesIntoKey(fcInfinity, fcZero):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNormal):
|
||||
case PackCategoriesIntoKey(fcZero, fcInfinity):
|
||||
case PackCategoriesIntoKey(fcZero, fcNormal):
|
||||
return opOK;
|
||||
|
||||
case PackCategoriesIntoKey(fcNormal, fcInfinity):
|
||||
@@ -1564,6 +1566,7 @@ APFloat::modSpecials(const APFloat &rhs)
|
||||
case PackCategoriesIntoKey(fcZero, fcNaN):
|
||||
case PackCategoriesIntoKey(fcNormal, fcNaN):
|
||||
case PackCategoriesIntoKey(fcInfinity, fcNaN):
|
||||
sign = false;
|
||||
category = fcNaN;
|
||||
copySignificand(rhs);
|
||||
return opOK;
|
||||
|
Reference in New Issue
Block a user