-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix: expose std.math.ldexp as C ldexp, scalbn and scalbln in compiler-rt to address LLVM release-mode simplification #24142
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
base: master
Are you sure you want to change the base?
Conversation
pub fn scalbln(x: f64, n: c_long) callconv(.c) f64 { | ||
// mirror musl implementation - clamp c_long to i32 | ||
const clamped_n: i32 = @intCast(math.clamp(n, math.minInt(i32), math.maxInt(i32))); | ||
return math.ldexp(x, clamped_n); | ||
} |
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.
Is this clamping behavior part of the C standard? We need to be careful about whether it should apply regardless of target.
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 @th3james.
Before this is merged:
- the logic for these functions need to move from std into compiler_rt
- new builtins need to be added for the functions
- the std code needs to be deleted in favor of calling those builtin functions
- new Legalize features added for expanding these builtin calls into compiler_rt calls
- llvm backend disables them and emits intrinsic calls
- other backends enable them
This is a pretty big scope increase, so you can hand it off to a core team member at any time.
Happy to hand this off to someone else, as a first issue this was already pushing the limits of my expertise and free time. I’ll leave my branch live in case it’s a useful point of reference, feel free to close this PR or convert it to an issue/draft as you see fit. |
Updated version of #24006
Fixes #23358
Changes:
Impact: