[flang-commits] [PATCH] D129672: [flang][runtime] Refine list-directed REAL(2) output
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Jul 13 11:36:06 PDT 2022
klausler created this revision.
klausler added reviewers: vdonaldson, clementval.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
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.
https://reviews.llvm.org/D129672
Files:
flang/runtime/edit-output.cpp
Index: flang/runtime/edit-output.cpp
===================================================================
--- flang/runtime/edit-output.cpp
+++ flang/runtime/edit-output.cpp
@@ -531,7 +531,12 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129672.444351.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220713/a91940e3/attachment.bin>
More information about the flang-commits
mailing list