[flang-commits] [PATCH] D128269: Teach fpcmp about the x. FP format

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Aug 12 02:31:25 PDT 2022


rovka updated this revision to Diff 452115.
rovka edited the summary of this revision.
rovka added a comment.

I think I got myself confused, flang does still print values in this format, and that's what's going to be in the reference outputs. Therefore, if we want to be able to pass this test when FCVS_ALLOW_FLEXIBLE_OUTPUT is enabled, we need to teach fpcmp how to handle this.

Updated the patch per @Meinersbur 's comments, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128269/new/

https://reviews.llvm.org/D128269

Files:
  tools/fpcmp.c


Index: tools/fpcmp.c
===================================================================
--- tools/fpcmp.c
+++ tools/fpcmp.c
@@ -62,16 +62,23 @@
     ++Pos;
 
   // Pre-decimal digits (optional)
+  bool HasPreDecimalDigit = false;
   while (Pos < End && isDigitChar(*Pos)) {
     ++Pos;
     EndOfNumber = Pos;
+    HasPreDecimalDigit = true;
   }
 
   // Decimal separator
   if (Pos < End && *Pos == '.') {
     ++Pos;
 
-    // Post-decimal digits (require at least one when period present)
+    // Only update the end of number if we're sure if we have a number (i.e. we
+    // have seen at least one digit so far).
+    if (HasPreDecimalDigit)
+      EndOfNumber = Pos;
+
+    // Post-decimal digits (optional if we have pre-decimal digits)
     bool HasPostDecimalDigit = false;
     while (Pos < End && isDigitChar(*Pos)) {
       HasPostDecimalDigit = true;
@@ -79,7 +86,7 @@
       ++Pos;
       EndOfNumber = Pos;
     }
-    if (!HasPostDecimalDigit)
+    if (!HasPreDecimalDigit && !HasPostDecimalDigit)
       return EndOfNumber;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128269.452115.patch
Type: text/x-patch
Size: 1051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220812/d23184dc/attachment-0001.bin>


More information about the flang-commits mailing list