From 41eb938a950708b249b91df74a74fcbefbf5ea7c Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 29 Dec 2022 18:11:05 +0800 Subject: [PATCH] Fix equal check in AOT XIP float cmp intrinsic (#1847) --- core/iwasm/aot/aot_intrinsic.c | 4 ++-- core/shared/utils/bh_platform.h | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index ba3feaf9..665be573 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -442,7 +442,7 @@ aot_intrinsic_f32_cmp(AOTFloatCond cond, float32 lhs, float32 rhs) { switch (cond) { case FLOAT_EQ: - return (float32)fabs(lhs - rhs) <= WA_FLT_EPSILON ? 1 : 0; + return lhs == rhs ? 1 : 0; case FLOAT_LT: return lhs < rhs ? 1 : 0; @@ -473,7 +473,7 @@ aot_intrinsic_f64_cmp(AOTFloatCond cond, float64 lhs, float64 rhs) { switch (cond) { case FLOAT_EQ: - return fabs(lhs - rhs) <= WA_DBL_EPSILON ? 1 : 0; + return lhs == rhs ? 1 : 0; case FLOAT_LT: return lhs < rhs ? 1 : 0; diff --git a/core/shared/utils/bh_platform.h b/core/shared/utils/bh_platform.h index 3bbd0c82..86aef839 100644 --- a/core/shared/utils/bh_platform.h +++ b/core/shared/utils/bh_platform.h @@ -35,9 +35,4 @@ #define WA_FREE wasm_runtime_free #endif -/* The epsilon value is from https://www.cplusplus.com/reference/cfloat/ */ - -#define WA_FLT_EPSILON 1e-5f -#define WA_DBL_EPSILON 1e-9 - #endif /* #ifndef _BH_PLATFORM_H */