From f062ef5f5923e9c3c83cdde5033235b111aae67e Mon Sep 17 00:00:00 2001 From: abdul124 Date: Fri, 5 Jul 2024 13:35:22 +0800 Subject: [PATCH] core/llvm_intrinsic: replace roundeven with rint --- nac3core/src/codegen/builtin_fns.rs | 4 ++-- nac3core/src/codegen/llvm_intrinsics.rs | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/nac3core/src/codegen/builtin_fns.rs b/nac3core/src/codegen/builtin_fns.rs index 272a61da..c87e2730 100644 --- a/nac3core/src/codegen/builtin_fns.rs +++ b/nac3core/src/codegen/builtin_fns.rs @@ -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!( diff --git a/nac3core/src/codegen/llvm_intrinsics.rs b/nac3core/src/codegen/llvm_intrinsics.rs index edbae506..2bba98e2 100644 --- a/nac3core/src/codegen/llvm_intrinsics.rs +++ b/nac3core/src/codegen/llvm_intrinsics.rs @@ -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();