summaryrefslogtreecommitdiff
path: root/src/support/safe_integer.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-07-21 09:15:27 -0700
committerGitHub <noreply@github.com>2020-07-21 09:15:27 -0700
commit71c9572e8bdcf05306e6df1fb3bd1afc924d2f83 (patch)
tree2e29b9b952b2eced617f26d315ec5683821300dc /src/support/safe_integer.cpp
parent8da3c515bd13b3621047849548b7dc0c5586ec89 (diff)
downloadbinaryen-71c9572e8bdcf05306e6df1fb3bd1afc924d2f83.tar.gz
binaryen-71c9572e8bdcf05306e6df1fb3bd1afc924d2f83.tar.bz2
binaryen-71c9572e8bdcf05306e6df1fb3bd1afc924d2f83.zip
Fix i32.trunc_f64_s of values near the limit of f64 representation (#2968)
See WebAssembly/spec#1223
Diffstat (limited to 'src/support/safe_integer.cpp')
-rw-r--r--src/support/safe_integer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp
index d43f7a6aa..9b6b56be0 100644
--- a/src/support/safe_integer.cpp
+++ b/src/support/safe_integer.cpp
@@ -124,7 +124,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) {
* 3 21098765432 1098...432109...210
* ---------------------------------
* 0 00000000000 0000...000000...000 0x0000000000000000 => 0
- * 0 10000011101 1111...111000...000 0x41dfffffffc00000 => 2147483647 (INT32_MAX)
+ * 0 10000011101 1111...111000...111 0x41dfffffffffffff => 2147483647.9999998 (rounds down to INT32_MAX)
* 0 10000011110 1111...111100...000 0x41efffffffe00000 => 4294967295 (UINT32_MAX)
* 0 10000111101 1111...111111...111 0x43dfffffffffffff => 9223372036854774784 (~INT64_MAX)
* 0 10000111110 0000...000000...000 0x43e0000000000000 => 9223372036854775808
@@ -146,7 +146,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) {
bool wasm::isInRangeI32TruncS(int64_t i) {
uint64_t u = i;
- return (u <= 0x41dfffffffc00000ULL) ||
+ return (u <= 0x41dfffffffffffffULL) ||
(u >= 0x8000000000000000ULL && u <= 0xc1e0000000000000ULL);
}