-
Notifications
You must be signed in to change notification settings - Fork 349
[Fortran] Add floating point to integer conversion test #220
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
[Fortran] Add floating point to integer conversion test #220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this test here! Works for me.
A couple notes:
|
I don't think the
I was thinking that myself but I don't know how to check for this off the top of my head. Maybe @jeanPerier knows, or knows of someone who does. |
EDIT: Apologies this would actually only work for a lit test. I think for unit tests you would need to duplicate the CMake logic for f128 support. You can see examples here https://github.com/llvm/llvm-project/pull/106957/files |
Thanks @tblah! If this test suite is not trying to be portable, maybe we could use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked for me on Linux on x86. Thanks.
9cbac91
to
2bc2d93
Compare
I split the test into two, one of which uses real(16) and is conditionally enabled. Also, since this is just for LLVM I added a quick check for NaN -> int conversions. Thanks for the reviews! Please LMK if there's anything else y'all would like changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update.
This correctly enabled r16 support and passed on my aarch64 system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Semantics for floating point conversions to integer types was changed in flang to use the saturated floating point intrinsics to more closely match the standard semantics in llvm-project#130686 . This tests conversions from tiny, huge and inf to various integer types.
I replicated the floating point conversion test for real(kind=16). Instead of trying to keep both tests in the same source file, I broke it into two tests and only enabled one when the fortran compiler can compile a test program using real16.
When the utility module had the same name in both tests, we get errors because of multiple build rules for the module. Renamed to resolve the conflict.
2bc2d93
to
2c633c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does fp_convert_r16.f90
need to do the same thing as fp_convert.f90
in addition to kind=16
? It looks like fp_convert.f90
is always built and run. Could we do just kind=16
in the other file then or am I missing something obvious>
The fp_convert_r16 test converts to some of the same types, but from real16 and also to int16 and unsigned16 - there should be no conversions that happen in both test cases. Is that what you were asking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does fp_convert_r16.f90 need to do the same thing as fp_convert.f90 in addition to kind=16?
The fp_convert_r16 test converts to some of the same types, but from real16 and also to int16 and unsigned16 - there should be no conversions that happen in both test cases. Is that what you were asking?
Ah, sorry. I didn't notice that value in do_conversion
is real(8)
in one and real(16)
in the other.
Thanks for clarifying. LGTM
Semantics for floating point conversions to integer types was changed in flang to use the saturated floating point intrinsics to more closely match the standard semantics in llvm-project#130686 . This tests conversions from tiny, huge, and inf to various integer types.