summaryrefslogtreecommitdiff
path: root/src/interp/interp-math.h
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2020-07-29 17:52:38 -0700
committerGitHub <noreply@github.com>2020-07-29 17:52:38 -0700
commit5390bb0c51023aef254d9a637d84b79bef9c03db (patch)
tree2cbb20c6b742c664ab0d0eda6868c1d16031e2dd /src/interp/interp-math.h
parent2402dedc1d95b75ba6a005c9ba686cb77f316c7f (diff)
downloadwabt-5390bb0c51023aef254d9a637d84b79bef9c03db.tar.gz
wabt-5390bb0c51023aef254d9a637d84b79bef9c03db.tar.bz2
wabt-5390bb0c51023aef254d9a637d84b79bef9c03db.zip
Update testsuite; fix conversion errors (#1502)
The interpreter and wasm2c were incorrectly handling some float-to-int conversions. For clarity, the wasm2c implementations of these conversions now matches the implementation in interp-math.h more closely (e.g. the numeric ranges are written as `x >= min && x <= max` in both cases). Quite a few wasm2c tests were previously being skipped, since wasm2c doesn't currently support multi-value; it's better instead to duplicate the tests here and disable the parts that are not supported so we don't lose test coverage.
Diffstat (limited to 'src/interp/interp-math.h')
-rw-r--r--src/interp/interp-math.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/interp/interp-math.h b/src/interp/interp-math.h
index f0ff96ef..3ae2666e 100644
--- a/src/interp/interp-math.h
+++ b/src/interp/interp-math.h
@@ -285,9 +285,9 @@ T WABT_VECTORCALL FloatMax(T lhs, T rhs) {
template <typename R, typename T> bool WABT_VECTORCALL CanConvert(T val) { return true; }
template <> inline bool WABT_VECTORCALL CanConvert<s32, f32>(f32 val) { return val >= -2147483648.f && val < 2147483648.f; }
-template <> inline bool WABT_VECTORCALL CanConvert<s32, f64>(f64 val) { return val >= -2147483648. && val <= 2147483647.; }
+template <> inline bool WABT_VECTORCALL CanConvert<s32, f64>(f64 val) { return val > -2147483649. && val < 2147483648.; }
template <> inline bool WABT_VECTORCALL CanConvert<u32, f32>(f32 val) { return val > -1.f && val < 4294967296.f; }
-template <> inline bool WABT_VECTORCALL CanConvert<u32, f64>(f64 val) { return val > -1. && val <= 4294967295.; }
+template <> inline bool WABT_VECTORCALL CanConvert<u32, f64>(f64 val) { return val > -1. && val < 4294967296.; }
template <> inline bool WABT_VECTORCALL CanConvert<s64, f32>(f32 val) { return val >= -9223372036854775808.f && val < 9223372036854775808.f; }
template <> inline bool WABT_VECTORCALL CanConvert<s64, f64>(f64 val) { return val >= -9223372036854775808. && val < 9223372036854775808.; }
template <> inline bool WABT_VECTORCALL CanConvert<u64, f32>(f32 val) { return val > -1.f && val < 18446744073709551616.f; }