diff options
25 files changed, 297 insertions, 277 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 24b7ee845..3952c765f 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -133,6 +133,57 @@ struct LocalScanner : PostWalker<LocalScanner> { } }; +namespace { +// perform some final optimizations +struct FinalOptimizer : public PostWalker<FinalOptimizer> { + const PassOptions& passOptions; + + FinalOptimizer(const PassOptions& passOptions) : passOptions(passOptions) {} + + void visitBinary(Binary* curr) { + if (auto* replacement = optimize(curr)) { + replaceCurrent(replacement); + } + } + + Binary* optimize(Binary* curr) { + using namespace Abstract; + using namespace Match; + { + Const* c; + if (matches(curr, binary(Add, any(), ival(&c)))) { + // normalize x + (-C) ==> x - C + if (c->value.isNegative()) { + c->value = c->value.neg(); + curr->op = Abstract::getBinary(c->type, Sub); + } + // Wasm binary encoding uses signed LEBs, which slightly favor negative + // numbers: -64 is more efficient than +64 etc., as well as other powers + // of two 7 bits etc. higher. we therefore prefer x - -64 over x + 64. + // in theory we could just prefer negative numbers over positive, but + // that can have bad effects on gzip compression (as it would mean more + // subtractions than the more common additions). + int64_t value = c->value.getInteger(); + if (value == 0x40LL || value == 0x2000LL || value == 0x100000LL || + value == 0x8000000LL || value == 0x400000000LL || + value == 0x20000000000LL || value == 0x1000000000000LL || + value == 0x80000000000000LL || value == 0x4000000000000000LL) { + c->value = c->value.neg(); + if (curr->op == Abstract::getBinary(c->type, Add)) { + curr->op = Abstract::getBinary(c->type, Sub); + } else { + curr->op = Abstract::getBinary(c->type, Add); + } + } + return curr; + } + } + return nullptr; + } +}; + +} // anonymous namespace + // Create a custom matcher for checking side effects template<class Opt> struct PureMatcherKind {}; template<class Opt> @@ -167,6 +218,10 @@ struct OptimizeInstructions } // main walk super::doWalkFunction(func); + { + FinalOptimizer optimizer(getPassOptions()); + optimizer.walkFunction(func); + } } void visitExpression(Expression* curr) { @@ -210,7 +265,7 @@ struct OptimizeInstructions FeatureSet features = getModule()->features; if (auto* binary = curr->dynCast<Binary>()) { - if (isSymmetricOrRelational(binary)) { + if (shouldCanonicalize(binary)) { canonicalize(binary); } } @@ -517,11 +572,8 @@ struct OptimizeInstructions } // note that both left and right may be consts, but then we let // precompute compute the constant result - } else if (binary->op == AddInt32 || binary->op == AddInt64) { - if (auto* ret = optimizeAddedConstants(binary)) { - return ret; - } - } else if (binary->op == SubInt32 || binary->op == SubInt64) { + } else if (binary->op == AddInt32 || binary->op == AddInt64 || + binary->op == SubInt32 || binary->op == SubInt64) { if (auto* ret = optimizeAddedConstants(binary)) { return ret; } @@ -895,7 +947,7 @@ private: // Canonicalizing the order of a symmetric binary helps us // write more concise pattern matching code elsewhere. void canonicalize(Binary* binary) { - assert(isSymmetricOrRelational(binary)); + assert(shouldCanonicalize(binary)); auto swap = [&]() { assert(canReorder(binary->left, binary->right)); if (binary->isRelational()) { @@ -912,7 +964,13 @@ private: if (binary->left->is<Const>() && !binary->right->is<Const>()) { return swap(); } - if (binary->right->is<Const>()) { + if (auto* c = binary->right->dynCast<Const>()) { + // x - C ==> x + (-C) + // Prefer use addition if there is a constant on the right. + if (binary->op == Abstract::getBinary(c->type, Abstract::Sub)) { + c->value = c->value.neg(); + binary->op = Abstract::getBinary(c->type, Abstract::Add); + } return; } // Prefer a get on the right. @@ -1199,6 +1257,10 @@ private: auto type = curr->type; auto* left = curr->left->dynCast<Const>(); auto* right = curr->right->dynCast<Const>(); + // Canonicalization prefers an add instead of a subtract wherever + // possible. That prevents a subtracted constant on the right, + // as it would be added. And for a zero on the left, it can't be + // removed (it is how we negate ints). if (curr->op == Abstract::getBinary(type, Abstract::Add)) { if (left && left->value.isZero()) { replaceCurrent(curr->right); @@ -1208,12 +1270,6 @@ private: replaceCurrent(curr->left); return; } - } else if (curr->op == Abstract::getBinary(type, Abstract::Sub)) { - // we must leave a left zero, as it is how we negate ints - if (right && right->value.isZero()) { - replaceCurrent(curr->left); - return; - } } else if (curr->op == Abstract::getBinary(type, Abstract::Shl)) { // shifting a 0 is a 0, or anything by 0 has no effect, all unless the // shift has side effects @@ -1713,30 +1769,6 @@ private: } } { - // Wasm binary encoding uses signed LEBs, which slightly favor negative - // numbers: -64 is more efficient than +64 etc., as well as other powers - // of two 7 bits etc. higher. we therefore prefer x - -64 over x + 64. in - // theory we could just prefer negative numbers over positive, but that - // can have bad effects on gzip compression (as it would mean more - // subtractions than the more common additions). TODO: Simplify this by - // adding an ival matcher than can bind int64_t vars. - int64_t value; - if ((matches(curr, binary(Add, any(), ival(&value))) || - matches(curr, binary(Sub, any(), ival(&value)))) && - (value == 0x40 || value == 0x2000 || value == 0x100000 || - value == 0x8000000 || value == 0x400000000LL || - value == 0x20000000000LL || value == 0x1000000000000LL || - value == 0x80000000000000LL || value == 0x4000000000000000LL)) { - right->value = right->value.neg(); - if (matches(curr, binary(Add, any(), constant()))) { - curr->op = Abstract::getBinary(type, Sub); - } else { - curr->op = Abstract::getBinary(type, Add); - } - return curr; - } - } - { double value; if (matches(curr, binary(Sub, any(), fval(&value))) && value == 0.0) { // x - (-0.0) ==> x + 0.0 @@ -1837,24 +1869,11 @@ private: curr->right = x; return curr; } - // C1 - (x - C2) ==> (C1 + C2) - x - if (matches(curr, - binary(Sub, ival(&c1), binary(Sub, any(&x), ival(&c2))))) { - left->value = c1->value.add(c2->value); - curr->right = x; - return curr; - } // C1 - (C2 - x) ==> x + (C1 - C2) if (matches(curr, binary(Sub, ival(&c1), binary(Sub, ival(&c2), any(&x))))) { left->value = c1->value.sub(c2->value); - if (left->value.isNegative()) { - // -C1 - (C2 - x) ==> x - (C1 - C2) - left->value = left->value.neg(); - curr->op = Abstract::getBinary(type, Sub); - } else { - curr->op = Abstract::getBinary(type, Add); - } + curr->op = Abstract::getBinary(type, Add); curr->right = x; std::swap(curr->left, curr->right); return curr; @@ -1884,17 +1903,14 @@ private: // x + 5 == 7 // => // x == 2 - if (left->op == Abstract::getBinary(type, Abstract::Add) || - left->op == Abstract::getBinary(type, Abstract::Sub)) { + if (left->op == Abstract::getBinary(type, Abstract::Add)) { if (auto* leftConst = left->right->dynCast<Const>()) { if (auto* rightConst = curr->right->dynCast<Const>()) { return combineRelationalConstants( curr, left, leftConst, nullptr, rightConst); } else if (auto* rightBinary = curr->right->dynCast<Binary>()) { if (rightBinary->op == - Abstract::getBinary(type, Abstract::Add) || - rightBinary->op == - Abstract::getBinary(type, Abstract::Sub)) { + Abstract::getBinary(type, Abstract::Add)) { if (auto* rightConst = rightBinary->right->dynCast<Const>()) { return combineRelationalConstants( curr, left, leftConst, rightBinary, rightConst); @@ -2389,7 +2405,11 @@ private: } } - bool isSymmetricOrRelational(Binary* binary) { + bool shouldCanonicalize(Binary* binary) { + if ((binary->op == SubInt32 || binary->op == SubInt64) && + binary->right->is<Const>() && !binary->left->is<Const>()) { + return true; + } if (Properties::isSymmetric(binary) || binary->isRelational()) { return true; } @@ -2413,6 +2433,6 @@ private: } }; -Pass* createOptimizeInstructionsPass() { return new OptimizeInstructions(); } +Pass* createOptimizeInstructionsPass() { return new OptimizeInstructions; } } // namespace wasm diff --git a/src/wasm2js.h b/src/wasm2js.h index 8ab6ab5cf..bdaa2f9f7 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -2588,7 +2588,7 @@ void Wasm2JSGlue::emitMemory( out << R"( return uint8Array;)"; } - out << R"( + out << R"( } )"; diff --git a/test/passes/O.bin.txt b/test/passes/O.bin.txt index 0e6d2d9a2..40ab1940f 100644 --- a/test/passes/O.bin.txt +++ b/test/passes/O.bin.txt @@ -93,9 +93,9 @@ (br_if $label$3 (i64.gt_s (local.tee $0 - (i64.add + (i64.sub (local.get $0) - (i64.const -1) + (i64.const 1) ) ) (i64.const 1) diff --git a/test/passes/O3_low-memory-unused_metrics.txt b/test/passes/O3_low-memory-unused_metrics.txt index f148cacd8..ce7ea2333 100644 --- a/test/passes/O3_low-memory-unused_metrics.txt +++ b/test/passes/O3_low-memory-unused_metrics.txt @@ -799,14 +799,14 @@ total ) ) (local.set $5 - (i32.add + (i32.sub (i32.shl (i32.load offset=48 (local.get $2) ) (i32.const 12) ) - (i32.const -30720) + (i32.const 30720) ) ) (local.set $3 @@ -2534,14 +2534,14 @@ total ) ) (local.tee $4 - (i32.add + (i32.sub (i32.shl (i32.load offset=76 (local.get $2) ) (i32.const 1) ) - (i32.const -2) + (i32.const 2) ) ) ) diff --git a/test/passes/asyncify_mod-asyncify-never-unwind_O.txt b/test/passes/asyncify_mod-asyncify-never-unwind_O.txt index bb233812c..d4840bfda 100644 --- a/test/passes/asyncify_mod-asyncify-never-unwind_O.txt +++ b/test/passes/asyncify_mod-asyncify-never-unwind_O.txt @@ -27,11 +27,11 @@ (block (result i32) (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (i32.load diff --git a/test/passes/asyncify_optimize-level=1.txt b/test/passes/asyncify_optimize-level=1.txt index 19e0cd160..c61ab8b04 100644 --- a/test/passes/asyncify_optimize-level=1.txt +++ b/test/passes/asyncify_optimize-level=1.txt @@ -29,11 +29,11 @@ (block (result i32) (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (i32.load @@ -91,11 +91,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $0 @@ -120,11 +120,11 @@ (block (result i32) (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (i32.load @@ -215,11 +215,11 @@ (block (result i32) (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (i32.load @@ -282,11 +282,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -308,11 +308,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $2 @@ -418,11 +418,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -494,11 +494,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -520,11 +520,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $2 @@ -656,11 +656,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -768,11 +768,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -794,11 +794,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $2 @@ -920,11 +920,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $0 @@ -946,11 +946,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $1 @@ -1046,11 +1046,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $0 @@ -1072,11 +1072,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $2 @@ -1171,11 +1171,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $0 @@ -1276,11 +1276,11 @@ (block (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (local.set $0 @@ -1384,11 +1384,11 @@ (block (result i32) (i32.store (global.get $__asyncify_data) - (i32.add + (i32.sub (i32.load (global.get $__asyncify_data) ) - (i32.const -4) + (i32.const 4) ) ) (i32.load diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt index fe69552fc..bb68dd500 100644 --- a/test/passes/converge_O3_metrics.bin.txt +++ b/test/passes/converge_O3_metrics.bin.txt @@ -85,11 +85,11 @@ total (i32.load offset=24 (i32.add (i32.load - (i32.add + (i32.sub (i32.load (i32.const 18100) ) - (i32.const -12) + (i32.const 12) ) ) (i32.const 18100) @@ -163,11 +163,11 @@ total (i32.load (i32.add (i32.load - (i32.add + (i32.sub (i32.load (i32.const 18100) ) - (i32.const -12) + (i32.const 12) ) ) (i32.const 18124) @@ -326,11 +326,11 @@ total (i32.load offset=24 (i32.add (i32.load - (i32.add + (i32.sub (i32.load (i32.const 18100) ) - (i32.const -12) + (i32.const 12) ) ) (i32.const 18100) @@ -404,11 +404,11 @@ total (i32.load (i32.add (i32.load - (i32.add + (i32.sub (i32.load (i32.const 18100) ) - (i32.const -12) + (i32.const 12) ) ) (i32.const 18124) diff --git a/test/passes/fannkuch3_manyopts_dwarf.bin.txt b/test/passes/fannkuch3_manyopts_dwarf.bin.txt index 9b9319c3e..dc002a6fb 100644 --- a/test/passes/fannkuch3_manyopts_dwarf.bin.txt +++ b/test/passes/fannkuch3_manyopts_dwarf.bin.txt @@ -4850,11 +4850,11 @@ file_names[ 4]: ;; code offset: 0x7d (local.tee $4 ;; code offset: 0x7c - (i32.add + (i32.sub ;; code offset: 0x78 (local.get $2) ;; code offset: 0x7a - (i32.const -1) + (i32.const 1) ) ) ) @@ -4912,11 +4912,11 @@ file_names[ 4]: ;; code offset: 0xaa (local.tee $1 ;; code offset: 0xa9 - (i32.add + (i32.sub ;; code offset: 0xa5 (local.get $2) ;; code offset: 0xa7 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0xac @@ -5020,11 +5020,11 @@ file_names[ 4]: ;; code offset: 0x101 (local.set $1 ;; code offset: 0x100 - (i32.add + (i32.sub ;; code offset: 0xfc (local.get $6) ;; code offset: 0xfe - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x105 @@ -5102,11 +5102,11 @@ file_names[ 4]: ;; code offset: 0x13d (local.tee $1 ;; code offset: 0x13c - (i32.add + (i32.sub ;; code offset: 0x138 (local.get $1) ;; code offset: 0x13a - (i32.const -1) + (i32.const 1) ) ) ) @@ -5301,7 +5301,7 @@ file_names[ 4]: ) ) ;; code offset: 0x1d5 - (i32.add + (i32.sub ;; code offset: 0x1d1 (local.tee $1 ;; code offset: 0x1ce @@ -5311,7 +5311,7 @@ file_names[ 4]: ) ) ;; code offset: 0x1d3 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x1de @@ -5379,11 +5379,11 @@ file_names[ 4]: ;; code offset: 0x20c (local.tee $4 ;; code offset: 0x20b - (i32.add + (i32.sub ;; code offset: 0x207 (local.get $2) ;; code offset: 0x209 - (i32.const -1) + (i32.const 1) ) ) ) @@ -5432,11 +5432,11 @@ file_names[ 4]: ;; code offset: 0x233 (local.tee $1 ;; code offset: 0x232 - (i32.add + (i32.sub ;; code offset: 0x22e (local.get $2) ;; code offset: 0x230 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x235 @@ -5530,11 +5530,11 @@ file_names[ 4]: ;; code offset: 0x282 (local.set $1 ;; code offset: 0x281 - (i32.add + (i32.sub ;; code offset: 0x27d (local.get $7) ;; code offset: 0x27f - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x286 @@ -5612,11 +5612,11 @@ file_names[ 4]: ;; code offset: 0x2be (local.tee $1 ;; code offset: 0x2bd - (i32.add + (i32.sub ;; code offset: 0x2b9 (local.get $1) ;; code offset: 0x2bb - (i32.const -1) + (i32.const 1) ) ) ) @@ -5811,7 +5811,7 @@ file_names[ 4]: ) ) ;; code offset: 0x356 - (i32.add + (i32.sub ;; code offset: 0x352 (local.tee $1 ;; code offset: 0x34f @@ -5821,7 +5821,7 @@ file_names[ 4]: ) ) ;; code offset: 0x354 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x35f @@ -5965,11 +5965,11 @@ file_names[ 4]: ;; code offset: 0x3d7 (local.set $2 ;; code offset: 0x3d6 - (i32.add + (i32.sub ;; code offset: 0x3d2 (local.get $3) ;; code offset: 0x3d4 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x3db @@ -6243,11 +6243,11 @@ file_names[ 4]: ;; code offset: 0x4aa (local.tee $0 ;; code offset: 0x4a9 - (i32.add + (i32.sub ;; code offset: 0x4a5 (local.get $2) ;; code offset: 0x4a7 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x4ac @@ -6292,11 +6292,11 @@ file_names[ 4]: ;; code offset: 0x4d2 (local.set $6 ;; code offset: 0x4d1 - (i32.add + (i32.sub ;; code offset: 0x4cd (local.get $6) ;; code offset: 0x4cf - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x4d4 @@ -6417,7 +6417,7 @@ file_names[ 4]: ) ) ;; code offset: 0x532 - (i32.add + (i32.sub ;; code offset: 0x52e (local.tee $0 ;; code offset: 0x52b @@ -6427,7 +6427,7 @@ file_names[ 4]: ) ) ;; code offset: 0x530 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x53b @@ -6504,11 +6504,11 @@ file_names[ 4]: ;; code offset: 0x56c (local.tee $0 ;; code offset: 0x56b - (i32.add + (i32.sub ;; code offset: 0x567 (local.get $2) ;; code offset: 0x569 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x56e @@ -6553,11 +6553,11 @@ file_names[ 4]: ;; code offset: 0x594 (local.set $6 ;; code offset: 0x593 - (i32.add + (i32.sub ;; code offset: 0x58f (local.get $6) ;; code offset: 0x591 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x596 @@ -6678,7 +6678,7 @@ file_names[ 4]: ) ) ;; code offset: 0x5f4 - (i32.add + (i32.sub ;; code offset: 0x5f0 (local.tee $0 ;; code offset: 0x5ed @@ -6688,7 +6688,7 @@ file_names[ 4]: ) ) ;; code offset: 0x5f2 - (i32.const -1) + (i32.const 1) ) ) ;; code offset: 0x5fd diff --git a/test/passes/inlining-optimizing_optimize-level=3.txt b/test/passes/inlining-optimizing_optimize-level=3.txt index d9a621099..c63b3baa3 100644 --- a/test/passes/inlining-optimizing_optimize-level=3.txt +++ b/test/passes/inlining-optimizing_optimize-level=3.txt @@ -2467,7 +2467,7 @@ (if (result i32) (i32.lt_u (local.tee $8 - (i32.add + (i32.sub (local.tee $12 (i32.load8_s (local.tee $10 @@ -2478,7 +2478,7 @@ ) ) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2562,9 +2562,9 @@ (i32.and (i32.shl (i32.const 1) - (i32.add + (i32.sub (local.get $6) - (i32.const -32) + (i32.const 32) ) ) (i32.const 75913) @@ -2583,7 +2583,7 @@ (i32.or (i32.shl (i32.const 1) - (i32.add + (i32.sub (i32.shr_s (i32.shl (local.get $1) @@ -2591,7 +2591,7 @@ ) (i32.const 24) ) - (i32.const -32) + (i32.const 32) ) ) (local.get $12) @@ -2642,7 +2642,7 @@ (br_if $__rjti$0 (i32.ge_u (local.tee $12 - (i32.add + (i32.sub (i32.load8_s (local.tee $6 (i32.add @@ -2651,7 +2651,7 @@ ) ) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2681,11 +2681,11 @@ (i32.add (local.get $3) (i32.shl - (i32.add + (i32.sub (i32.load8_s (local.get $6) ) - (i32.const -48) + (i32.const 48) ) (i32.const 3) ) @@ -2790,7 +2790,7 @@ (if (result i32) (i32.lt_u (local.tee $6 - (i32.add + (i32.sub (i32.shr_s (i32.shl (local.get $6) @@ -2798,7 +2798,7 @@ ) (i32.const 24) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2820,7 +2820,7 @@ (if (i32.lt_u (local.tee $9 - (i32.add + (i32.sub (i32.load8_s (local.tee $10 (i32.add @@ -2829,7 +2829,7 @@ ) ) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2907,9 +2907,9 @@ (if (result i32) (i32.lt_u (local.tee $9 - (i32.add + (i32.sub (local.get $8) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2947,7 +2947,7 @@ ) (i32.ge_u (local.tee $6 - (i32.add + (i32.sub (i32.load8_s (local.tee $10 (i32.add @@ -2956,7 +2956,7 @@ ) ) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -2970,7 +2970,7 @@ (if (i32.lt_u (local.tee $8 - (i32.add + (i32.sub (i32.load8_s (local.tee $6 (i32.add @@ -2979,7 +2979,7 @@ ) ) ) - (i32.const -48) + (i32.const 48) ) ) (i32.const 10) @@ -3008,11 +3008,11 @@ (i32.add (local.get $3) (i32.shl - (i32.add + (i32.sub (i32.load8_s (local.get $6) ) - (i32.const -48) + (i32.const 48) ) (i32.const 3) ) @@ -3095,11 +3095,11 @@ (if (i32.gt_u (local.tee $11 - (i32.add + (i32.sub (i32.load8_s (local.get $8) ) - (i32.const -65) + (i32.const 65) ) ) (i32.const 57) @@ -3119,7 +3119,7 @@ ) (if (result i32) (i32.lt_u - (i32.add + (i32.sub (local.tee $11 (i32.and (local.tee $15 @@ -3139,7 +3139,7 @@ (i32.const 255) ) ) - (i32.const -1) + (i32.const 1) ) (i32.const 8) ) @@ -3548,9 +3548,9 @@ (loop $while-in32 (i32.store8 (local.tee $8 - (i32.add + (i32.sub (local.get $8) - (i32.const -1) + (i32.const 1) ) ) (i32.or @@ -3926,11 +3926,11 @@ ) (i32.store (local.get $21) - (i32.add + (i32.sub (i32.load (local.get $21) ) - (i32.const -1) + (i32.const 1) ) ) ) @@ -3990,9 +3990,9 @@ ) (br_if $while-in54 (local.tee $5 - (i32.add + (i32.sub (local.get $5) - (i32.const -1) + (i32.const 1) ) ) ) @@ -4079,9 +4079,9 @@ ) ) (i32.store8 - (i32.add + (i32.sub (local.get $5) - (i32.const -1) + (i32.const 1) ) (i32.add (i32.and @@ -4096,9 +4096,9 @@ ) (i32.store8 (local.tee $8 - (i32.add + (i32.sub (local.get $5) - (i32.const -2) + (i32.const 2) ) ) (i32.add @@ -4375,11 +4375,11 @@ (i32.store (local.get $21) (local.tee $5 - (i32.add + (i32.sub (i32.load (local.get $21) ) - (i32.const -28) + (i32.const 28) ) ) ) @@ -4490,9 +4490,9 @@ (if (i32.ge_u (local.tee $9 - (i32.add + (i32.sub (local.get $7) - (i32.const -4) + (i32.const 4) ) ) (local.get $5) @@ -4548,9 +4548,9 @@ (br_if $while-in66 (i32.ge_u (local.tee $9 - (i32.add + (i32.sub (local.get $9) - (i32.const -4) + (i32.const 4) ) ) (local.get $5) @@ -4564,9 +4564,9 @@ ) (i32.store (local.tee $5 - (i32.add + (i32.sub (local.get $5) - (i32.const -4) + (i32.const 4) ) ) (local.get $11) @@ -4583,9 +4583,9 @@ (i32.eqz (i32.load (local.tee $9 - (i32.add + (i32.sub (local.get $7) - (i32.const -4) + (i32.const 4) ) ) ) @@ -4686,12 +4686,12 @@ ) (block $do-once71 (local.set $11 - (i32.add + (i32.sub (i32.shl (i32.const 1) (local.get $15) ) - (i32.const -1) + (i32.const 1) ) ) (local.set $35 @@ -4946,7 +4946,7 @@ ) ) ) - (i32.add + (i32.sub (i32.mul (i32.shr_s (i32.sub @@ -4957,7 +4957,7 @@ ) (i32.const 9) ) - (i32.const -9) + (i32.const 9) ) ) (block (result i32) @@ -5017,7 +5017,7 @@ (local.tee $8 (i32.load (local.tee $6 - (i32.add + (i32.sub (i32.add (local.get $20) (i32.shl @@ -5025,7 +5025,7 @@ (i32.const 2) ) ) - (i32.const -4092) + (i32.const 4092) ) ) ) @@ -5167,18 +5167,18 @@ (if (i32.lt_u (local.tee $6 - (i32.add + (i32.sub (local.get $6) - (i32.const -4) + (i32.const 4) ) ) (local.get $5) ) (i32.store (local.tee $5 - (i32.add + (i32.sub (local.get $5) - (i32.const -4) + (i32.const 4) ) ) (i32.const 0) @@ -5306,9 +5306,9 @@ (if (result i32) (i32.load (local.tee $7 - (i32.add + (i32.sub (local.get $5) - (i32.const -4) + (i32.const 4) ) ) ) @@ -5363,28 +5363,28 @@ (block (result i32) (local.set $19 (i32.sub - (i32.add + (i32.sub (local.get $5) - (i32.const -1) + (i32.const 1) ) (local.get $8) ) ) - (i32.add + (i32.sub (local.get $16) - (i32.const -1) + (i32.const 1) ) ) (block (result i32) (local.set $19 - (i32.add + (i32.sub (local.get $5) - (i32.const -1) + (i32.const 1) ) ) - (i32.add + (i32.sub (local.get $16) - (i32.const -2) + (i32.const 2) ) ) ) @@ -5407,9 +5407,9 @@ (i32.eqz (local.tee $16 (i32.load - (i32.add + (i32.sub (local.get $9) - (i32.const -4) + (i32.const 4) ) ) ) @@ -5474,7 +5474,7 @@ ) ) (local.set $6 - (i32.add + (i32.sub (i32.mul (i32.shr_s (i32.sub @@ -5485,7 +5485,7 @@ ) (i32.const 9) ) - (i32.const -9) + (i32.const 9) ) ) (if (result i32) @@ -5643,9 +5643,9 @@ (loop $while-in98 (i32.store8 (local.tee $6 - (i32.add + (i32.sub (local.get $6) - (i32.const -1) + (i32.const 1) ) ) (i32.const 48) @@ -5662,9 +5662,9 @@ ) ) (i32.store8 - (i32.add + (i32.sub (local.get $6) - (i32.const -1) + (i32.const 1) ) (i32.add (i32.and @@ -5679,9 +5679,9 @@ ) (i32.store8 (local.tee $16 - (i32.add + (i32.sub (local.get $6) - (i32.const -2) + (i32.const 2) ) ) (local.get $7) @@ -5779,9 +5779,9 @@ (loop $while-in106 (i32.store8 (local.tee $7 - (i32.add + (i32.sub (local.get $7) - (i32.const -1) + (i32.const 1) ) ) (i32.const 48) @@ -5886,9 +5886,9 @@ (loop $while-in112 (i32.store8 (local.tee $6 - (i32.add + (i32.sub (local.get $6) - (i32.const -1) + (i32.const 1) ) ) (i32.const 48) @@ -5926,9 +5926,9 @@ ) ) (local.set $6 - (i32.add + (i32.sub (local.get $5) - (i32.const -9) + (i32.const 9) ) ) (if (result i32) @@ -6085,9 +6085,9 @@ (loop $while-in118 (i32.store8 (local.tee $5 - (i32.add + (i32.sub (local.get $5) - (i32.const -1) + (i32.const 1) ) ) (i32.const 48) @@ -6359,9 +6359,9 @@ (loop $while-in123 (result i32) (i32.store8 (local.tee $8 - (i32.add + (i32.sub (local.get $8) - (i32.const -1) + (i32.const 1) ) ) (i32.or @@ -7353,9 +7353,9 @@ (loop $while-in (i32.store8 (local.tee $2 - (i32.add + (i32.sub (local.get $2) - (i32.const -1) + (i32.const 1) ) ) (i32.or @@ -7398,9 +7398,9 @@ (loop $while-in1 (i32.store8 (local.tee $2 - (i32.add + (i32.sub (local.get $2) - (i32.const -1) + (i32.const 1) ) ) (i32.or diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt index 4a58c210f..a5cc470fb 100644 --- a/test/passes/optimize-instructions_all-features.txt +++ b/test/passes/optimize-instructions_all-features.txt @@ -818,16 +818,16 @@ (local.get $0) ) (i32.store offset=2 - (i32.add + (i32.sub (local.get $0) - (i32.const -11) + (i32.const 11) ) (local.get $0) ) (i32.store offset=2 - (i32.add + (i32.sub (local.get $0) - (i32.const -13) + (i32.const 13) ) (local.get $0) ) @@ -1369,12 +1369,12 @@ ) ) (drop - (i32.add + (i32.sub (i32.shl (local.get $1) (i32.const 3) ) - (i32.const -66) + (i32.const 66) ) ) (drop @@ -2529,25 +2529,25 @@ ) ) (func $optimizeAddedConstants-filters-through-nonzero (result i32) - (i32.add + (i32.sub (i32.shl (i32.const -536870912) (i32.wrap_i64 (i64.const 0) ) ) - (i32.const -31744) + (i32.const 31744) ) ) (func $optimizeAddedConstants-filters-through-nonzero-b (result i32) - (i32.add + (i32.sub (i32.shl (i32.const -536870912) (i32.wrap_i64 (i64.const -1) ) ) - (i32.const -31744) + (i32.const 31744) ) ) (func $return-proper-value-from-shift-left-by-zero (result i32) @@ -3424,7 +3424,7 @@ ) (drop (i32.eq - (i32.sub + (i32.add (local.get $x32) (i32.const 30) ) @@ -4205,15 +4205,15 @@ ) (func $rhs-is-neg-one (param $x i32) (param $y i64) (param $fx f32) (param $fy f64) (drop - (i32.sub + (i32.add (local.get $x) - (i32.const -1) + (i32.const 1) ) ) (drop - (i64.sub + (i64.add (local.get $y) - (i64.const -1) + (i64.const 1) ) ) (drop diff --git a/test/passes/optimize-instructions_optimize-level=2_all-features_ignore-implicit-traps.txt b/test/passes/optimize-instructions_optimize-level=2_all-features_ignore-implicit-traps.txt index 235944062..e450f9cc8 100644 --- a/test/passes/optimize-instructions_optimize-level=2_all-features_ignore-implicit-traps.txt +++ b/test/passes/optimize-instructions_optimize-level=2_all-features_ignore-implicit-traps.txt @@ -261,9 +261,9 @@ (i32.and (i32.shr_s (i32.shl - (i32.add + (i32.sub (local.get $1) - (i32.const -1) + (i32.const 1) ) (i32.const 24) ) @@ -300,9 +300,9 @@ (i32.and (i32.shr_s (i32.shl - (i32.add + (i32.sub (local.get $0) - (i32.const -1) + (i32.const 1) ) (i32.const 24) ) diff --git a/test/wasm2js/atomics_32.2asm.js b/test/wasm2js/atomics_32.2asm.js index 12cdbe8ff..d3c1ba22b 100644 --- a/test/wasm2js/atomics_32.2asm.js +++ b/test/wasm2js/atomics_32.2asm.js @@ -147,7 +147,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "aGVsbG8s"); memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29ybGQh"); diff --git a/test/wasm2js/atomics_32.2asm.js.opt b/test/wasm2js/atomics_32.2asm.js.opt index 4a7a5d85f..a12b684dc 100644 --- a/test/wasm2js/atomics_32.2asm.js.opt +++ b/test/wasm2js/atomics_32.2asm.js.opt @@ -143,7 +143,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "aGVsbG8s"); memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29ybGQh"); diff --git a/test/wasm2js/bulk-memory.2asm.js b/test/wasm2js/bulk-memory.2asm.js index 2b7431486..c847dbdfd 100644 --- a/test/wasm2js/bulk-memory.2asm.js +++ b/test/wasm2js/bulk-memory.2asm.js @@ -180,7 +180,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -287,7 +287,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(4), 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -405,7 +405,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(0), 0, ""); base64DecodeToExistingUint8Array(bufferView, 0, ""); diff --git a/test/wasm2js/bulk-memory.2asm.js.opt b/test/wasm2js/bulk-memory.2asm.js.opt index 77e682c41..4e6ccc529 100644 --- a/test/wasm2js/bulk-memory.2asm.js.opt +++ b/test/wasm2js/bulk-memory.2asm.js.opt @@ -180,7 +180,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -287,7 +287,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(4), 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } diff --git a/test/wasm2js/dynamicLibrary.2asm.js b/test/wasm2js/dynamicLibrary.2asm.js index b570fab36..22d483f45 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js +++ b/test/wasm2js/dynamicLibrary.2asm.js @@ -81,7 +81,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }, diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt index 4d7b4ac42..cd959acb8 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js.opt +++ b/test/wasm2js/dynamicLibrary.2asm.js.opt @@ -73,7 +73,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }, diff --git a/test/wasm2js/emscripten-grow-no.2asm.js b/test/wasm2js/emscripten-grow-no.2asm.js index 998527287..4d6bb4c77 100644 --- a/test/wasm2js/emscripten-grow-no.2asm.js +++ b/test/wasm2js/emscripten-grow-no.2asm.js @@ -63,7 +63,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-no.2asm.js.opt b/test/wasm2js/emscripten-grow-no.2asm.js.opt index 998527287..4d6bb4c77 100644 --- a/test/wasm2js/emscripten-grow-no.2asm.js.opt +++ b/test/wasm2js/emscripten-grow-no.2asm.js.opt @@ -63,7 +63,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-yes.2asm.js b/test/wasm2js/emscripten-grow-yes.2asm.js index 3cb5371b1..213524377 100644 --- a/test/wasm2js/emscripten-grow-yes.2asm.js +++ b/test/wasm2js/emscripten-grow-yes.2asm.js @@ -87,7 +87,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-yes.2asm.js.opt b/test/wasm2js/emscripten-grow-yes.2asm.js.opt index 3cb5371b1..213524377 100644 --- a/test/wasm2js/emscripten-grow-yes.2asm.js.opt +++ b/test/wasm2js/emscripten-grow-yes.2asm.js.opt @@ -87,7 +87,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten.2asm.js b/test/wasm2js/emscripten.2asm.js index 9d08b03a2..e71aaaa83 100644 --- a/test/wasm2js/emscripten.2asm.js +++ b/test/wasm2js/emscripten.2asm.js @@ -220,7 +220,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1024, "aGVsbG8sIHdvcmxkIQoAAJwMAAAtKyAgIDBYMHgAKG51bGwpAAAAAAAAAAAAAAAAEQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAETCQsLAAAJBgsAAAsABhEAAAAREREAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAEQAKChEREQAKAAACAAkLAAAACQALAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAADAAAAAAJDAAAAAAADAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAANAAAABA0AAAAACQ4AAAAAAA4AAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAASEhIAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAKAAAAAAoAAAAACQsAAAAAAAsAAAsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAMAAAAAAkMAAAAAAAMAAAMAAAwMTIzNDU2Nzg5QUJDREVGLTBYKzBYIDBYLTB4KzB4IDB4AGluZgBJTkYAbmFuAE5BTgAuAA=="); base64DecodeToExistingUint8Array(bufferView, 1600, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="); diff --git a/test/wasm2js/emscripten.2asm.js.opt b/test/wasm2js/emscripten.2asm.js.opt index 0e438f81d..05ecfea7d 100644 --- a/test/wasm2js/emscripten.2asm.js.opt +++ b/test/wasm2js/emscripten.2asm.js.opt @@ -201,7 +201,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1024, "aGVsbG8sIHdvcmxkIQoAAJwMAAAtKyAgIDBYMHgAKG51bGwp"); base64DecodeToExistingUint8Array(bufferView, 1072, "EQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAETCQsLAAAJBgsAAAsABhEAAAARERE="); diff --git a/test/wasm2js/i64-ctz.2asm.js.opt b/test/wasm2js/i64-ctz.2asm.js.opt index aaacbfc51..9cda827f4 100644 --- a/test/wasm2js/i64-ctz.2asm.js.opt +++ b/test/wasm2js/i64-ctz.2asm.js.opt @@ -30,8 +30,8 @@ function asmFunc(env) { function __wasm_ctz_i64($0, $1) { var $2 = 0, $3 = 0; if ($0 | $1) { - $2 = $1 + -1 | 0; - $3 = $0 + -1 | 0; + $2 = $1 - 1 | 0; + $3 = $0 - 1 | 0; $2 = ($3 | 0) != -1 ? $2 + 1 | 0 : $2; $3 = Math_clz32($0 ^ $3) + 32 | 0; $0 = Math_clz32($1 ^ $2); diff --git a/test/wasm2js/unary-ops.2asm.js.opt b/test/wasm2js/unary-ops.2asm.js.opt index b854489b6..272ea822c 100644 --- a/test/wasm2js/unary-ops.2asm.js.opt +++ b/test/wasm2js/unary-ops.2asm.js.opt @@ -26,7 +26,7 @@ function asmFunc(env) { function $7($0) { $0 = $0 | 0; if ($0) { - $0 = 31 - Math_clz32($0 + -1 ^ $0) | 0 + $0 = 31 - Math_clz32($0 - 1 ^ $0) | 0 } else { $0 = 32 } @@ -71,8 +71,8 @@ function asmFunc(env) { function __wasm_ctz_i64($0, $1_1) { var $2 = 0, $3 = 0; if ($0 | $1_1) { - $2 = $1_1 + -1 | 0; - $3 = $0 + -1 | 0; + $2 = $1_1 - 1 | 0; + $3 = $0 - 1 | 0; $2 = ($3 | 0) != -1 ? $2 + 1 | 0 : $2; $3 = Math_clz32($0 ^ $3) + 32 | 0; $0 = Math_clz32($1_1 ^ $2); |