Skip to content
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

libm optimizations #41

Open
parasyte opened this issue Dec 27, 2020 · 0 comments
Open

libm optimizations #41

parasyte opened this issue Dec 27, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@parasyte
Copy link
Collaborator

We're currently using libm to implement the missing compiler builtins for f32 and f64 primitives. The libm crate implements these builtins in Rust. While it provides a very workable springboard to get started quickly, it leaves a lot to be desired with fast math.

The N64 CPU supports many of these operations natively through the floating point unit, COP1. Here's a table summarizing the builtin to FPU instruction relationships:

builtin FPU instruction
fabs abs.d
fabsf abs.s
ceil ceil.l.d, cvt.d.l
ceilf ceil.w.s, cvt.s.w
floor floor.l.d, cvt.d.l
floorf floor.w.s, cvt.s.w
round round.l.d, cvt.d.l
roundf round.w.s, cvt.s.w
sqrt sqrt.d
sqrtf sqrt.s
trunc trunc.l.d, cvt.d.l
truncf trunc.w.s, cvt.s.w

Another alternative is using LLVM intrinsics from rustc. (How?)

@parasyte parasyte added the enhancement New feature or request label Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant