summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2020-10-02 09:12:36 +0300
committerGitHub <noreply@github.com>2020-10-01 23:12:36 -0700
commit42aec827c2233eb4adbb56c6d1b23d70399bfac1 (patch)
tree0e580f9f87b43cb8129ee162bd6015bab3f73e58 /src/emscripten-optimizer
parent2959218552a202b2b1d983ffcff68b015b9a94bd (diff)
downloadbinaryen-42aec827c2233eb4adbb56c6d1b23d70399bfac1.tar.gz
binaryen-42aec827c2233eb4adbb56c6d1b23d70399bfac1.tar.bz2
binaryen-42aec827c2233eb4adbb56c6d1b23d70399bfac1.zip
Simplify some numeric code (#3186)
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r--src/emscripten-optimizer/optimizer-shared.cpp2
-rw-r--r--src/emscripten-optimizer/simple_ast.h4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/emscripten-optimizer/optimizer-shared.cpp b/src/emscripten-optimizer/optimizer-shared.cpp
index 172b9f45f..d763dc17d 100644
--- a/src/emscripten-optimizer/optimizer-shared.cpp
+++ b/src/emscripten-optimizer/optimizer-shared.cpp
@@ -189,7 +189,7 @@ AsmSign detectSign(Ref node, IString minifiedFround) {
if (value < 0) {
return ASM_SIGNED;
}
- if (value > uint32_t(-1) || fmod(value, 1) != 0) {
+ if (value > uint32_t(-1) || !wasm::isInteger(value)) {
return ASM_NONSIGNED;
}
if (wasm::isSInteger32(value)) {
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h
index be5b4fa21..70ecb2acd 100644
--- a/src/emscripten-optimizer/simple_ast.h
+++ b/src/emscripten-optimizer/simple_ast.h
@@ -256,7 +256,7 @@ struct Value {
AssignName* asAssignName();
int32_t getInteger() { // convenience function to get a known integer
- assert(fmod(getNumber(), 1) == 0);
+ assert(wasm::isInteger(getNumber()));
int32_t ret = getNumber();
assert(double(ret) == getNumber()); // no loss in conversion
return ret;
@@ -944,7 +944,7 @@ struct JSPrinter {
d = -d;
}
// try to emit the fewest necessary characters
- bool integer = fmod(d, 1) == 0;
+ bool integer = wasm::isInteger(d);
#define BUFFERSIZE 1000
// f is normal, e is scientific for float, x for integer
static char full_storage_f[BUFFERSIZE], full_storage_e[BUFFERSIZE];