[flang] Rename some NaNs.
authorpeter klausler <pklausler@nvidia.com>
Fri, 3 Aug 2018 23:02:05 +0000 (16:02 -0700)
committerpeter klausler <pklausler@nvidia.com>
Fri, 3 Aug 2018 23:24:03 +0000 (16:24 -0700)
Original-commit: flang-compiler/f18@34eac17ddc11e83991e80ffe4f4937382ce07674
Reviewed-on: https://github.com/flang-compiler/f18/pull/162
Tree-same-pre-rewrite: false

flang/lib/evaluate/complex.h
flang/lib/evaluate/int-power.h
flang/lib/evaluate/real.cc
flang/lib/evaluate/real.h

index a8d481e..ae6989d 100644 (file)
@@ -78,7 +78,9 @@ public:
     return {re_.FlushDenormalToZero(), im_.FlushDenormalToZero()};
   }
 
-  static constexpr Complex NaN() { return {Part::NaN(), Part::NaN()}; }
+  static constexpr Complex NotANumber() {
+    return {Part::NotANumber(), Part::NotANumber()};
+  }
 
   std::string DumpHexadecimal() const;
   // TODO: (C)ABS once Real::HYPOT is done
index 66a9ceb..6f8a574 100644 (file)
@@ -28,7 +28,7 @@ ValueWithRealFlags<REAL> IntPower(
   ValueWithRealFlags<REAL> result;
   result.value = one;
   if (base.IsNotANumber()) {
-    result.value = REAL::NaN();
+    result.value = REAL::NotANumber();
     if (base.IsSignalingNaN()) {
       result.flags.set(RealFlag::InvalidArgument);
     }
index 95c999a..49ce0fa 100644 (file)
@@ -60,7 +60,7 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Add(
     const Real &y, Rounding rounding) const {
   ValueWithRealFlags<Real> result;
   if (IsNotANumber() || y.IsNotANumber()) {
-    result.value = NaN();  // NaN + x -> NaN
+    result.value = NotANumber();  // NaN + x -> NaN
     if (IsSignalingNaN() || y.IsSignalingNaN()) {
       result.flags.set(RealFlag::InvalidArgument);
     }
@@ -73,7 +73,7 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Add(
       if (isNegative == yIsNegative) {
         result.value = *this;  // +/-Inf + +/-Inf -> +/-Inf
       } else {
-        result.value = NaN();  // +/-Inf + -/+Inf -> NaN
+        result.value = NotANumber();  // +/-Inf + -/+Inf -> NaN
         result.flags.set(RealFlag::InvalidArgument);
       }
     } else {
@@ -140,7 +140,7 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Multiply(
     const Real &y, Rounding rounding) const {
   ValueWithRealFlags<Real> result;
   if (IsNotANumber() || y.IsNotANumber()) {
-    result.value = NaN();  // NaN * x -> NaN
+    result.value = NotANumber();  // NaN * x -> NaN
     if (IsSignalingNaN() || y.IsSignalingNaN()) {
       result.flags.set(RealFlag::InvalidArgument);
     }
@@ -148,7 +148,7 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Multiply(
     bool isNegative{IsNegative() != y.IsNegative()};
     if (IsInfinite() || y.IsInfinite()) {
       if (IsZero() || y.IsZero()) {
-        result.value = NaN();  // 0 * Inf -> NaN
+        result.value = NotANumber();  // 0 * Inf -> NaN
         result.flags.set(RealFlag::InvalidArgument);
       } else {
         result.value = Infinity(isNegative);
@@ -200,7 +200,7 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Divide(
     const Real &y, Rounding rounding) const {
   ValueWithRealFlags<Real> result;
   if (IsNotANumber() || y.IsNotANumber()) {
-    result.value = NaN();  // NaN / x -> NaN, x / NaN -> NaN
+    result.value = NotANumber();  // NaN / x -> NaN, x / NaN -> NaN
     if (IsSignalingNaN() || y.IsSignalingNaN()) {
       result.flags.set(RealFlag::InvalidArgument);
     }
@@ -208,14 +208,14 @@ ValueWithRealFlags<Real<W, P, IM>> Real<W, P, IM>::Divide(
     bool isNegative{IsNegative() != y.IsNegative()};
     if (IsInfinite()) {
       if (y.IsInfinite()) {
-        result.value = NaN();  // Inf/Inf -> NaN
+        result.value = NotANumber();  // Inf/Inf -> NaN
         result.flags.set(RealFlag::InvalidArgument);
       } else {  // Inf/x -> Inf,  Inf/0 -> Inf
         result.value = Infinity(isNegative);
       }
     } else if (y.IsZero()) {
       if (IsZero()) {  // 0/0 -> NaN
-        result.value = NaN();
+        result.value = NotANumber();
         result.flags.set(RealFlag::InvalidArgument);
       } else {  // x/0 -> Inf, Inf/0 -> Inf
         result.value = Infinity(isNegative);
index bb11403..50557b9 100644 (file)
@@ -124,8 +124,8 @@ public:
     return *this;
   }
 
-  // TODO: Configurable NaN representations
-  static constexpr Real NaN() {
+  // TODO: Configurable NotANumber representations
+  static constexpr Real NotANumber() {
     return {Word{maxExponent}
                 .SHIFTL(significandBits)
                 .IBSET(significandBits - 1)
@@ -310,7 +310,7 @@ private:
   }
 
   // Normalizes and marshals the fields of a floating-point number in place.
-  // The value is not a NaN, and a zero fraction means a zero value (i.e.,
+  // The value is a number, and a zero fraction means a zero value (i.e.,
   // a maximal exponent and zero fraction doesn't signify infinity, although
   // this member function will detect overflow and encode infinities).
   RealFlags Normalize(bool negative, std::uint64_t exponent,