[flang-commits] [flang] 29c3ef5 - Remove blank from NaN string representation
V Donaldson via flang-commits
flang-commits at lists.llvm.org
Fri Sep 3 08:10:01 PDT 2021
Author: V Donaldson
Date: 2021-09-03T08:09:55-07:00
New Revision: 29c3ef5a0e5f129ee7e0b5416a93484f4ecebf35
URL: https://github.com/llvm/llvm-project/commit/29c3ef5a0e5f129ee7e0b5416a93484f4ecebf35
DIFF: https://github.com/llvm/llvm-project/commit/29c3ef5a0e5f129ee7e0b5416a93484f4ecebf35.diff
LOG: Remove blank from NaN string representation
Flang front end function DumpHexadecimal generates a string
representation of a REAL value. When the value is a NaN, the string
contains a blank, as in "NaN 0x7fc00000". This function is used by
lowering to generate a string that is then passed to llvm Support
function convertFromStringSpecials, which does not expect a blank
in the string. Remove the blank to allow correct recognition of a
NaN by this llvm function.
Note that function DumpHexadecimal is not exercised by the front end
itself. This functionality is only exercised by code that is not yet
present in llvm.
Added:
Modified:
flang/lib/Evaluate/real.cpp
flang/unittests/Evaluate/real.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/real.cpp b/flang/lib/Evaluate/real.cpp
index 1428d52db0905..2146789049bea 100644
--- a/flang/lib/Evaluate/real.cpp
+++ b/flang/lib/Evaluate/real.cpp
@@ -439,7 +439,7 @@ ValueWithRealFlags<Real<W, P>> Real<W, P>::Read(
template <typename W, int P> std::string Real<W, P>::DumpHexadecimal() const {
if (IsNotANumber()) {
- return "NaN 0x"s + word_.Hexadecimal();
+ return "NaN0x"s + word_.Hexadecimal();
} else if (IsNegative()) {
return "-"s + Negate().DumpHexadecimal();
} else if (IsInfinite()) {
diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index d4c7ce5fb1aa3..af06e7a688c30 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -24,7 +24,7 @@ void dumpTest() {
std::uint64_t raw;
const char *expected;
} table[] = {
- {0x7f876543, "NaN 0x7f876543"},
+ {0x7f876543, "NaN0x7f876543"},
{0x7f800000, "Inf"},
{0xff800000, "-Inf"},
{0x00000000, "0.0"},
More information about the flang-commits
mailing list