This is an archive of the discontinued LLVM Phabricator instance.

Teach fpcmp about the x. FP format
Needs ReviewPublic

Authored by rovka on Jun 21 2022, 5:59 AM.

Details

Summary

At the moment fpcmp rejects floating point numbers with no decimal
digits after the decimal point, such as "3.". However, flang-new often
prints floating point numbers in this format and it seems to be
a perfectly respectable format (strtod is happy enough to gobble it up).

This patch updates fpcmp to allow the absence of post-decimal digits
if pre-decimal digits are present.

Diff Detail

Event Timeline

rovka created this revision.Jun 21 2022, 5:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2022, 5:59 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
rovka requested review of this revision.Jun 21 2022, 5:59 AM
Meinersbur added a comment.EditedJun 30 2022, 2:03 PM

I fear there is the problem that any single dot will be interpreted as a number. I tried strtod(".") (https://godbolt.org/z/Ke9n4zbn5) and it doesn't gobble it up. So we need to check that there are either digits before or after the period, but cannot omit both.

I don't think we need the compatibility flag. This patch would make fpcmp only more tolerant, so there would be any new test failures.

rovka abandoned this revision.Jul 25 2022, 5:04 AM

Looks like flang isn't using this format anymore. We can resurrect this patch some other time if we have a need for it. Thanks for the comments though!

rovka updated this revision to Diff 452115.Aug 12 2022, 2:31 AM
rovka edited the summary of this revision. (Show Details)

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!