-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add round_to_even to floating point types #82273
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,6 +573,8 @@ impl CodegenCx<'b, 'tcx> { | |
ifn!("llvm.copysign.f64", fn(t_f64, t_f64) -> t_f64); | ||
ifn!("llvm.round.f32", fn(t_f32) -> t_f32); | ||
ifn!("llvm.round.f64", fn(t_f64) -> t_f64); | ||
ifn!("llvm.roundeven.f32", fn(t_f32) -> t_f32); | ||
ifn!("llvm.roundeven.f64", fn(t_f64) -> t_f64); | ||
Comment on lines
+576
to
+577
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nagisa Can you confirm it's okay to add these llvm intrinsics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. It is documented here. How available it is across different backends is a different question, however – a quick look suggests these lower to native instructions on aarch64 and x86 only (and maybe amdgpu). Everything else will lower to libm calls. |
||
|
||
ifn!("llvm.rint.f32", fn(t_f32) -> t_f32); | ||
ifn!("llvm.rint.f64", fn(t_f64) -> t_f64); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -931,6 +931,8 @@ symbols! { | |
rlib, | ||
rotate_left, | ||
rotate_right, | ||
roundevenf32, | ||
roundevenf64, | ||
roundf32, | ||
roundf64, | ||
rt, | ||
|
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.
If I understand correctly, this will cause calls to the
roundeven
androundevenf
libc functions. But those are non-standard, and not available on all libc implementations.cc @bjorn3
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.
Cranelift doesn't have an instruction for this. If this ever becomes a problem, I can request one.