diff options
author | Peter Klausler <pklausler@nvidia.com> | 2022-07-07 09:32:21 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2022-07-13 16:10:46 -0700 |
commit | faffcc3a46cb667fb8e2e6d0e6c14ed74300d7b5 (patch) | |
tree | 4365a4a49df3d833c83fc1612a1f5e17f217976d | |
parent | 8b391cd908aafd1b1d948bd86fb6ed7550dad49a (diff) | |
download | llvm-faffcc3a46cb667fb8e2e6d0e6c14ed74300d7b5.zip llvm-faffcc3a46cb667fb8e2e6d0e6c14ed74300d7b5.tar.gz llvm-faffcc3a46cb667fb8e2e6d0e6c14ed74300d7b5.tar.bz2 |
[flang][runtime] Refine list-directed REAL(2) output
The rule used by list-directed REAL output editing to select
between Ew.d and Fw.d output editing breaks down for 16-bit
floating-point data, since the number of significant decimal
digits is so low that Ew,d output editing is nearly always selected.
Cap the test so that five-digit values will be output with Fw.d
editing.
Differential Revision: https://reviews.llvm.org/D129672
-rw-r--r-- | flang/runtime/edit-output.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp index 6ccaa00..b49e222 100644 --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -531,7 +531,12 @@ bool RealOutputEditing<binaryPrecision>::EditListDirectedOutput( return EditEorDOutput(edit); } int expo{converted.decimalExponent}; - if (expo < 0 || expo > BinaryFloatingPoint::decimalPrecision) { + // The decimal precision of 16-bit floating-point types is very low, + // so use a reasonable cap of 6 to allow more values to be emitted + // with Fw.d editing. + static constexpr int maxExpo{ + std::max(6, BinaryFloatingPoint::decimalPrecision)}; + if (expo < 0 || expo > maxExpo) { DataEdit copy{edit}; copy.modes.scale = 1; // 1P return EditEorDOutput(copy); |