You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code for round (adapted from musl libm) is correct (I verified it for all f32 values) but slow, containing many branches.
The following code is also correct and should be much faster (this is the f32 version, which is the main thing I'm testing now, since I'm looking at simd). This is the positive branch.
There are two ways to make this work for signed values: one is to branch on the sign of the argument, the other is to do copysign(... x.abs() ..., x). The copysign intrinsic is not currently exposed in the Rust std lib though, for which I'll file an issue. One of the nice things about copysign is that there's a wasm intrinsic. That should get this function down to around 9 asm instructions from the current ~92.
It would also be really nice to expose the nearest wasm instruction as well; the problem is that there's no llvm intrinsic with the exactly correct semantics. I'm going to be exploring that as well.
The text was updated successfully, but these errors were encountered:
This bug is branched from rust-lang/rust#55107.
The code for round (adapted from musl libm) is correct (I verified it for all f32 values) but slow, containing many branches.
The following code is also correct and should be much faster (this is the f32 version, which is the main thing I'm testing now, since I'm looking at simd). This is the positive branch.
There are two ways to make this work for signed values: one is to branch on the sign of the argument, the other is to do
copysign(... x.abs() ..., x)
. The copysign intrinsic is not currently exposed in the Rust std lib though, for which I'll file an issue. One of the nice things about copysign is that there's a wasm intrinsic. That should get this function down to around 9 asm instructions from the current ~92.It would also be really nice to expose the
nearest
wasm instruction as well; the problem is that there's no llvm intrinsic with the exactly correct semantics. I'm going to be exploring that as well.The text was updated successfully, but these errors were encountered: