Fix equal check in AOT XIP float cmp intrinsic (#1847)

This commit is contained in:
Huang Qi 2022-12-29 18:11:05 +08:00 committed by GitHub
parent 6c7ca90229
commit 41eb938a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 7 deletions

View File

@ -442,7 +442,7 @@ aot_intrinsic_f32_cmp(AOTFloatCond cond, float32 lhs, float32 rhs)
{ {
switch (cond) { switch (cond) {
case FLOAT_EQ: case FLOAT_EQ:
return (float32)fabs(lhs - rhs) <= WA_FLT_EPSILON ? 1 : 0; return lhs == rhs ? 1 : 0;
case FLOAT_LT: case FLOAT_LT:
return lhs < rhs ? 1 : 0; return lhs < rhs ? 1 : 0;
@ -473,7 +473,7 @@ aot_intrinsic_f64_cmp(AOTFloatCond cond, float64 lhs, float64 rhs)
{ {
switch (cond) { switch (cond) {
case FLOAT_EQ: case FLOAT_EQ:
return fabs(lhs - rhs) <= WA_DBL_EPSILON ? 1 : 0; return lhs == rhs ? 1 : 0;
case FLOAT_LT: case FLOAT_LT:
return lhs < rhs ? 1 : 0; return lhs < rhs ? 1 : 0;

View File

@ -35,9 +35,4 @@
#define WA_FREE wasm_runtime_free #define WA_FREE wasm_runtime_free
#endif #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 */ #endif /* #ifndef _BH_PLATFORM_H */