Skip to content

Conversation

@FranciscoTGouveia
Copy link
Contributor

@FranciscoTGouveia FranciscoTGouveia commented Oct 26, 2025

Fixes #4642.

I would appreciate feedback on the following:

  • Initially, I decided to add two test cases -- one for f32 and another for f64 -- but I later concluded that this might be redundant. If not, I am happy to reintroduce the second one;
  • I have thoroughly looked into the documentation of rustc_apfloat, and the only suitable solution I have found was from_bits. I may have overlooked something, but going through the codebase, I did not find any other way to do this;
  • As all operations done (to_bits() -> cast -> from_bits()) are bit-preserving, I do not think we need to worry about signaling NaNs here. Am I correct thinking this should not be problematic?

Thank you in advance for your time and input!

@rustbot
Copy link
Collaborator

rustbot commented Oct 26, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Oct 26, 2025
}
ty::Float(FloatTy::F32) => {
let x = unsafe { ffi::call::<f32>(fun, libffi_args) };
Scalar::from_f32(Single::from_bits(u128::from(x.to_bits())))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Scalar::from_f32(Single::from_bits(u128::from(x.to_bits())))
Scalar::from_f32(x.to_soft())

This should work after importing the ToSoft trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I overlooked that.
My apologies -- I have corrected it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting for a review to complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support f32/f64 in native function calls.

3 participants