Skip to content

fpcmp: Allow decimal numbers ending with a period #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025

Conversation

SixWeining
Copy link
Contributor

After 8a84a50, fpcmp requires at least one post-decimal digit when period present. This leads to incorrect comparison results for 628.pop2_s of SPEC2017 because this program outputs 65. if the Fortran compiler is flang while the reference output is 65.0.

@tarunprabhu
Copy link
Contributor

Thanks for working on this. Could you add one or more tests in tools/test? There are some there that you may be model off of, if needed. That may help prevent regressions like this.

After 8a84a50, fpcmp requires at least one post-decimal digit when
period present. This leads to incorrect comparison results for
628.pop2_s of SPEC2017 because this program outputs `65.` when the
Fortran compiler is flang while the reference output is `65.0`.
@SixWeining
Copy link
Contributor Author

Thanks for working on this. Could you add one or more tests in tools/test? There are some there that you may be model off of, if needed. That may help prevent regressions like this.

Thanks. Added.

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests.

@@ -19,6 +23,10 @@ add_dependencies(abrt not)
llvm_test_run(EXECUTABLE "$<TARGET_FILE:not>" "--crash" "$<TARGET_FILE:abrt>")
llvm_add_test_for_target(abrt)

# Check that fpcmp can handle decimal numbers ending with a period correctly.
llvm_test_run(EXECUTABLE "$<TARGET_FILE:fpcmp-target>" "-a" "0.03" "-r" "0.03" "-i" "%b/test/fpcmp-input1" "%b/test/fpcmp-input2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tolerance of 0.03 here seems fairly large. Do you expect that it will fail if it is made smaller?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

628_pop2 uses 0.03 for both absolute and relative tolerance.

# SPEC Test has both absolute and relative tolerance with same order
speccpu2017_verify_output(IGNORE_WHITESPACE ABSOLUTE_TOLERANCE 0.03 RELATIVE_TOLERANCE 0.03)

How about using a bigger value in the test file? For example: change 3.0E-02 to 1003.0E-02.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

628_pop2 uses 0.03 for both absolute and relative tolerance.

# SPEC Test has both absolute and relative tolerance with same order
speccpu2017_verify_output(IGNORE_WHITESPACE ABSOLUTE_TOLERANCE 0.03 RELATIVE_TOLERANCE 0.03)

How about using a bigger value in the test file? For example: change 3.0E-02 to 1003.0E-02.

Thanks for the clarification. Since this was motivated by 628_pop2 anyway, the tolerance is probably appropriate. There's no need for larger values.

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. We should consider adding more tests to explicitly check for error conditions, whitespace etc. but that can be done separately.

LGTM.

@SixWeining SixWeining merged commit 45c296d into llvm:main Jun 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants