core/llvm_intrinsic: use llvm.rint for rounding #447

Merged
sb10q merged 1 commits from issue-396 into master 2024-07-07 14:24:33 +08:00
2 changed files with 5 additions and 7 deletions

View File

@ -419,7 +419,7 @@ pub fn call_numpy_round<'ctx, G: CodeGenerator + ?Sized>(
BasicValueEnum::FloatValue(n) => {
debug_assert!(ctx.unifier.unioned(n_ty, ctx.primitives.float));
llvm_intrinsics::call_float_roundeven(ctx, n, None).into()
llvm_intrinsics::call_float_rint(ctx, n, None).into()
}
BasicValueEnum::PointerValue(n)
@ -1383,7 +1383,7 @@ create_helper_call_numpy_unary_elementwise_float_to_float!(
create_helper_call_numpy_unary_elementwise_float_to_float!(
call_numpy_rint,
"np_rint",
llvm_intrinsics::call_float_roundeven
llvm_intrinsics::call_float_rint
);
create_helper_call_numpy_unary_elementwise_float_to_float!(

View File

@ -684,15 +684,13 @@ pub fn call_float_round<'ctx>(
.unwrap()
}
/// Invokes the
/// [`llvm.nearbyint`](https://llvm.org/docs/LangRef.html#llvm-nearbyint-intrinsic)
/// Note [`llvm.roundeven`](https://llvm.org/docs/LangRef.html#llvm-roundeven-intrinsic) not supported on all platforms
pub fn call_float_roundeven<'ctx>(
/// Invokes the [`llvm.rint`](https://llvm.org/docs/LangRef.html#llvm-rint-intrinsic) intrinsic.
pub fn call_float_rint<'ctx>(
ctx: &CodeGenContext<'ctx, '_>,
val: FloatValue<'ctx>,
name: Option<&str>,
) -> FloatValue<'ctx> {
const FN_NAME: &str = "llvm.nearbyint";
const FN_NAME: &str = "llvm.rint";
let llvm_float_t = val.get_type();