summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-08 18:47:17 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-08 21:27:26 -0700
commit8efc401621d1794c057bfb43345b6ac4d615b2e0 (patch)
tree85ef9aa857a0a7bb17873ab55bfc01c63c526519
parentf046fa3a19252e2dc301a82e7f699aec4dc2eb43 (diff)
downloadbinaryen-8efc401621d1794c057bfb43345b6ac4d615b2e0.tar.gz
binaryen-8efc401621d1794c057bfb43345b6ac4d615b2e0.tar.bz2
binaryen-8efc401621d1794c057bfb43345b6ac4d615b2e0.zip
AST Builder class, and use it to optimzie umoddi4 in asm2wasm
-rw-r--r--src/asm2wasm.h112
-rw-r--r--src/emscripten-optimizer/parser.cpp2
-rw-r--r--src/emscripten-optimizer/parser.h2
-rw-r--r--src/wasm-builder.h116
-rw-r--r--src/wasm.h5
-rw-r--r--test/emcc_hello_world.asm.js2
-rw-r--r--test/emcc_hello_world.fromasm1218
-rw-r--r--test/emcc_hello_world.fromasm.imprecise1218
8 files changed, 302 insertions, 2373 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 1aca67eff..a3cbb95c7 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -29,6 +29,7 @@
#include "asm_v_wasm.h"
#include "pass.h"
#include "ast_utils.h"
+#include "wasm-builder.h"
namespace wasm {
@@ -206,6 +207,10 @@ private:
IString tempDoublePtr; // imported name of tempDoublePtr
+ // possibly-minified names, detected via their exports
+ IString udivmoddi4;
+ IString getTempRet0;
+
// function types. we fill in this information as we see
// uses, in the first pass
@@ -664,6 +669,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
// asm.js memory growth provides this special non-asm function, which we don't need (we use grow_memory)
assert(!wasm.checkFunction(value));
continue;
+ } else if (key == UDIVMODDI4) {
+ udivmoddi4 = value;
+ } else if (key == GET_TEMP_RET0) {
+ getTempRet0 = value;
}
assert(wasm.checkFunction(value));
auto export_ = allocator.alloc<Export>();
@@ -746,10 +755,108 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
}
wasm.memory.exportName = MEMORY;
+
+ if (udivmoddi4.is()) {
+ // generate a wasm-optimized __udivmoddi4 method, which we can do much more efficiently in wasm
+ assert(getTempRet0.is());
+ // first, figure out which minified global is tempRet0
+ int tempRet0;
+ {
+ Expression* curr = wasm.getFunction(getTempRet0)->body;
+ if (curr->is<Block>()) curr = curr->cast<Block>()->list[0];
+ curr = curr->cast<Return>()->value;
+ auto* load = curr->cast<Load>();
+ auto* ptr = load->ptr->cast<Const>();
+ tempRet0 = ptr->value.geti32() + load->offset;
+ }
+ // udivmoddi4 receives xl, xh, yl, yl, r, and
+ // if r then *r = x % y
+ // returns x / y
+ auto* func = wasm.getFunction(udivmoddi4);
+ assert(!func->type.is());
+ Name xl = func->params[0].name,
+ xh = func->params[1].name,
+ yl = func->params[2].name,
+ yh = func->params[3].name,
+ r = func->params[4].name;
+ func->locals.clear();
+ Name x64("x64"), y64("y64");
+ func->locals.emplace_back(x64, i64);
+ func->locals.emplace_back(y64, i64);
+ Builder builder(wasm);
+ auto* body = allocator.alloc<Block>();
+ auto recreateI64 = [&](Name target, Name low, Name high) {
+ return builder.makeSetLocal(
+ target,
+ builder.makeBinary(
+ Or,
+ builder.makeUnary(
+ ExtendUInt32,
+ builder.makeGetLocal(low, i32)
+ ),
+ builder.makeBinary(
+ Shl,
+ builder.makeUnary(
+ ExtendUInt32,
+ builder.makeGetLocal(high, i32)
+ ),
+ builder.makeConst(Literal(int64_t(32)))
+ )
+ )
+ );
+ };
+ body->list.push_back(recreateI64(x64, xl, xh));
+ body->list.push_back(recreateI64(y64, yl, yh));
+ body->list.push_back(
+ builder.makeIf(
+ builder.makeGetLocal(r, i32),
+ builder.makeStore(
+ 8, 0, 8,
+ builder.makeGetLocal(r, i32),
+ builder.makeBinary(
+ RemU,
+ builder.makeGetLocal(x64, i64),
+ builder.makeGetLocal(y64, i64)
+ )
+ )
+ )
+ );
+ body->list.push_back(
+ builder.makeSetLocal(
+ x64,
+ builder.makeBinary(
+ DivU,
+ builder.makeGetLocal(x64, i64),
+ builder.makeGetLocal(y64, i64)
+ )
+ )
+ );
+ body->list.push_back(
+ builder.makeStore(
+ 4, 0, 4,
+ builder.makeConst(Literal(int32_t(tempRet0))),
+ builder.makeUnary(
+ WrapInt64,
+ builder.makeBinary(
+ ShrU,
+ builder.makeGetLocal(x64, i64),
+ builder.makeConst(Literal(int64_t(32)))
+ )
+ )
+ )
+ );
+ body->list.push_back(
+ builder.makeUnary(
+ WrapInt64,
+ builder.makeGetLocal(x64, i64)
+ )
+ );
+ func->body = body;
+ }
}
Function* Asm2WasmBuilder::processFunction(Ref ast) {
- //if (ast[1] != IString("qta")) return nullptr;
+ auto name = ast[1]->getIString();
if (debug) {
std::cout << "\nfunc: " << ast[1]->getIString().str << '\n';
@@ -758,7 +865,7 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
}
auto function = allocator.alloc<Function>();
- function->name = ast[1]->getIString();
+ function->name = name;
Ref params = ast[2];
Ref body = ast[3];
@@ -1601,7 +1708,6 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
// cleanups/checks
assert(breakStack.size() == 0 && continueStack.size() == 0);
assert(parentLabel.isNull());
-
return function;
}
diff --git a/src/emscripten-optimizer/parser.cpp b/src/emscripten-optimizer/parser.cpp
index ce4737476..b8297fc29 100644
--- a/src/emscripten-optimizer/parser.cpp
+++ b/src/emscripten-optimizer/parser.cpp
@@ -48,7 +48,9 @@ IString TOPLEVEL("toplevel"),
INF("inf"),
NaN("nan"),
TEMP_RET0("tempRet0"),
+ GET_TEMP_RET0("getTempRet0"),
LLVM_CTTZ_I32("_llvm_cttz_i32"),
+ UDIVMODDI4("___udivmoddi4"),
UNARY_PREFIX("unary-prefix"),
UNARY_POSTFIX("unary-postfix"),
MATH_FROUND("Math_fround"),
diff --git a/src/emscripten-optimizer/parser.h b/src/emscripten-optimizer/parser.h
index e10044fbc..367c831e2 100644
--- a/src/emscripten-optimizer/parser.h
+++ b/src/emscripten-optimizer/parser.h
@@ -63,7 +63,9 @@ extern IString TOPLEVEL,
INF,
NaN,
TEMP_RET0,
+ GET_TEMP_RET0,
LLVM_CTTZ_I32,
+ UDIVMODDI4,
UNARY_PREFIX,
UNARY_POSTFIX,
MATH_FROUND,
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
new file mode 100644
index 000000000..de3371274
--- /dev/null
+++ b/src/wasm-builder.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 WebAssembly Community Group participants
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef wasm_builder_h
+#define wasm_builder_h
+
+#include <wasm.h>
+
+namespace wasm {
+
+class Builder {
+ MixedArena &allocator;
+
+public:
+ Builder(AllocatingModule& wasm) : allocator(wasm.allocator) {}
+
+ // Nop TODO: add all the rest
+ // Block
+ If* makeIf(Expression* condition, Expression* ifTrue, Expression* ifFalse=nullptr) {
+ auto* ret = allocator.alloc<If>();
+ ret->condition = condition; ret->ifTrue = ifTrue; ret->ifFalse = ifFalse;
+ ret->finalize();
+ return ret;
+ }
+ // Loop
+ // Break
+ // Switch
+ // CallBase
+ // Call
+ // CallImport
+ // FunctionType
+ GetLocal* makeGetLocal(Name name, WasmType type) {
+ auto* ret = allocator.alloc<GetLocal>();
+ ret->name = name;
+ ret->type = type;
+ return ret;
+ }
+ SetLocal* makeSetLocal(Name name, Expression* value) {
+ auto* ret = allocator.alloc<SetLocal>();
+ ret->name = name;
+ ret->value = value;
+ ret->type = value->type;
+ return ret;
+ }
+ // Load
+ Store* makeStore(unsigned bytes, uint32_t offset, unsigned align, Expression *ptr, Expression *value) {
+ auto* ret = allocator.alloc<Store>();
+ ret->bytes = bytes; ret->offset = offset; ret->align = align; ret->ptr = ptr; ret->value = value;
+ ret->type = value->type;
+ return ret;
+ }
+ Const* makeConst(Literal value) {
+ auto* ret = allocator.alloc<Const>();
+ ret->value = value;
+ ret->type = value.type;
+ return ret;
+ }
+ Unary* makeUnary(UnaryOp op, Expression *value, WasmType type=none) {
+ auto* ret = allocator.alloc<Unary>();
+ ret->op = op; ret->value = value;
+ if (type != none) {
+ ret->type = type; // some opcodes have more than one type, user must provide it
+ } else {
+ switch (op) {
+ case Clz:
+ case Ctz:
+ case Popcnt:
+ case Neg:
+ case Abs:
+ case Ceil:
+ case Floor:
+ case Trunc:
+ case Nearest:
+ case Sqrt: ret->type = value->type; break;
+ case EqZ: ret->type = i32; break;
+ case ExtendSInt32: case ExtendUInt32: ret->type = i64; break;
+ case WrapInt64: ret->type = i32; break;
+ case PromoteFloat32: ret->type = f64; break;
+ case DemoteFloat64: ret->type = f32; break;
+ case TruncSFloat32: case TruncUFloat32: case TruncSFloat64: case TruncUFloat64: case ReinterpretFloat:
+ case ConvertSInt32: case ConvertUInt32: case ConvertSInt64: case ConvertUInt64: case ReinterpretInt: abort(); // user needs to say the type
+ default: abort();
+ }
+ }
+ return ret;
+ }
+ Binary* makeBinary(BinaryOp op, Expression *left, Expression *right) {
+ auto* ret = allocator.alloc<Binary>();
+ ret->op = op; ret->left = left; ret->right = right;
+ ret->finalize();
+ return ret;
+ }
+ // Select
+ // Return
+ // Host
+ // Unreachable
+
+};
+
+} // namespace wasm
+
+#endif // wasm_builder_h
+
diff --git a/src/wasm.h b/src/wasm.h
index 2fa117b91..a064a3431 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -975,10 +975,9 @@ public:
UnaryOp op;
Expression *value;
- // the type is always the type of the operands,
- // except for relationals
-
bool isRelational() { return op == EqZ; }
+
+ // no finalize since some opcodes have more than one type, so user must set it anyhow
};
class Binary : public Expression {
diff --git a/test/emcc_hello_world.asm.js b/test/emcc_hello_world.asm.js
index 3a47a258b..cd188303e 100644
--- a/test/emcc_hello_world.asm.js
+++ b/test/emcc_hello_world.asm.js
@@ -7096,6 +7096,6 @@ var FUNCTION_TABLE_ii = [b0,___stdio_close];
var FUNCTION_TABLE_iiii = [b1,b1,___stdout_write,___stdio_seek,___stdio_write,b1,b1,b1];
var FUNCTION_TABLE_vi = [b2,b2,b2,b2,b2,_cleanup,b2,b2];
- return { _i64Subtract: _i64Subtract, _free: _free, _main: _main, _i64Add: _i64Add, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, _bitshift64Lshr: _bitshift64Lshr, _fflush: _fflush, ___errno_location: ___errno_location, _bitshift64Shl: _bitshift64Shl, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, establishStackSpace: establishStackSpace, setThrew: setThrew, setTempRet0: setTempRet0, getTempRet0: getTempRet0, dynCall_ii: dynCall_ii, dynCall_iiii: dynCall_iiii, dynCall_vi: dynCall_vi };
+ return { _i64Subtract: _i64Subtract, _free: _free, _main: _main, _i64Add: _i64Add, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, _bitshift64Lshr: _bitshift64Lshr, _fflush: _fflush, ___errno_location: ___errno_location, _bitshift64Shl: _bitshift64Shl, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, establishStackSpace: establishStackSpace, setThrew: setThrew, setTempRet0: setTempRet0, getTempRet0: getTempRet0, dynCall_ii: dynCall_ii, dynCall_iiii: dynCall_iiii, dynCall_vi: dynCall_vi, ___udivmoddi4: ___udivmoddi4 };
})
;
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 5c41777c7..381e53407 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -50,6 +50,7 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
+ (export "___udivmoddi4" $___udivmoddi4)
(table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $size i32) (result i32)
(local $ret i32)
@@ -29146,1209 +29147,60 @@
)
)
(func $___udivmoddi4 (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (param $$rem i32) (result i32)
- (local $$_0$1 i32)
- (local $$_0$0 i32)
- (local $$n_sroa_1_4_extract_trunc i32)
- (local $$n_sroa_0_0_extract_trunc i32)
- (local $$d_sroa_0_0_extract_trunc i32)
- (local $$d_sroa_1_4_extract_trunc i32)
- (local $$88 i32)
- (local $$sr_1_ph i32)
- (local $$r_sroa_1_1_ph i32)
- (local $$r_sroa_0_1_ph i32)
- (local $$q_sroa_1_1_ph i32)
- (local $$q_sroa_0_1_ph i32)
- (local $$r_sroa_0_1201 i32)
- (local $$q_sroa_1_1198 i32)
- (local $$q_sroa_0_1199 i32)
- (local $$q_sroa_0_0_insert_ext75$0 i32)
- (local $$n_sroa_1_4_extract_shift$0 i32)
- (local $$91 i32)
- (local $$78 i32)
- (local $$57 i32)
- (local $$150$1 i32)
- (local $$125 i32)
- (local $$119 i32)
- (local $$sr_1202 i32)
- (local $$r_sroa_1_4_extract_trunc i32)
- (local $$r_sroa_1_1_lcssa i32)
- (local $$r_sroa_1_1200 i32)
- (local $$r_sroa_0_1_lcssa i32)
- (local $$r_sroa_0_0_insert_insert42$1 i32)
- (local $$r_sroa_0_0_insert_insert42$0 i32)
- (local $$r_sroa_0_0_extract_trunc i32)
- (local $$q_sroa_1_1_lcssa i32)
- (local $$q_sroa_0_1_lcssa i32)
- (local $$q_sroa_0_0_insert_ext75$1 i32)
- (local $$d_sroa_0_0_insert_insert99$1 i32)
- (local $$d_sroa_0_0_insert_insert99$0 i32)
- (local $$carry_0_lcssa$1 i32)
- (local $$carry_0_lcssa$0 i32)
- (local $$carry_0203 i32)
- (local $$95 i32)
- (local $$92 i32)
- (local $$89 i32)
- (local $$58 i32)
- (local $$51 i32)
- (local $$4 i32)
- (local $$17 i32)
- (local $$152 i32)
- (local $$149 i32)
- (local $$147 i32)
- (local $$130 i32)
- (local $$126 i32)
- (local $$105 i32)
- (local $$q_sroa_0_0_insert_insert77$1 i32)
- (local $$d_sroa_1_4_extract_shift$0 i32)
- (local $$66 i32)
- (local $$37 i32)
- (local $$155 i32)
- (local $$151$0 i32)
- (local $$137$1 i32)
- (local $$137$0 i32)
- (local $$86 i32)
- (local $$49 i32)
- (local $$154$0 i32)
- (local $$117 i32)
- (set_local $$n_sroa_0_0_extract_trunc
- (get_local $$a$0)
- )
- (set_local $$n_sroa_1_4_extract_trunc
- (set_local $$n_sroa_1_4_extract_shift$0
- (get_local $$a$1)
- )
- )
- (set_local $$d_sroa_0_0_extract_trunc
- (get_local $$b$0)
- )
- (set_local $$d_sroa_1_4_extract_trunc
- (set_local $$d_sroa_1_4_extract_shift$0
- (get_local $$b$1)
- )
- )
- (if
- (i32.eq
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- (block
- (set_local $$4
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
+ (local $x64 i64)
+ (local $y64 i64)
+ (set_local $x64
+ (i64.or
+ (i64.extend_u/i32
+ (get_local $$a$0)
)
- (if
- (i32.eq
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (get_local $$4)
- (block
- (i32.store
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (if
- (i32.eqz
- (get_local $$4)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_local $$a$1)
)
+ (i64.const 32)
)
)
)
- (set_local $$17
- (i32.eq
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- )
- (block $do-once$0
- (if
- (i32.eq
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (get_local $$17)
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.eq
- (get_local $$n_sroa_0_0_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.const 0)
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.eq
- (i32.and
- (set_local $$37
- (i32.sub
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- (i32.const 0)
- )
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (i32.and
- (get_local $$37)
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.ctz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.le_u
- (set_local $$51
- (i32.sub
- (set_local $$49
- (i32.clz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- (i32.const 30)
- )
- (block
- (set_local $$57
- (i32.add
- (get_local $$51)
- (i32.const 1)
- )
- )
- (set_local $$58
- (i32.sub
- (i32.const 31)
- (get_local $$51)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$57)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$58)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$57)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$57)
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.const 0)
- )
- (set_local $$q_sroa_1_1_ph
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$58)
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.eq
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (if
- (i32.eqz
- (get_local $$17)
- )
- (block
- (if
- (i32.le_u
- (set_local $$119
- (i32.sub
- (set_local $$117
- (i32.clz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- (i32.const 31)
- )
- (block
- (set_local $$125
- (i32.add
- (get_local $$119)
- (i32.const 1)
- )
- )
- (set_local $$126
- (i32.sub
- (i32.const 31)
- (get_local $$119)
- )
- )
- (set_local $$130
- (i32.shr_s
- (i32.sub
- (get_local $$119)
- (i32.const 31)
- )
- (i32.const 31)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$125)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.and
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$125)
- )
- (get_local $$130)
- )
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$126)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.and
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$125)
- )
- (get_local $$130)
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.const 0)
- )
- (set_local $$q_sroa_1_1_ph
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$126)
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.eq
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.ne
- (i32.and
- (set_local $$66
- (i32.sub
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- (i32.const 0)
- )
- (block
- (set_local $$89
- (i32.sub
- (i32.const 64)
- (set_local $$88
- (i32.sub
- (set_local $$86
- (i32.add
- (i32.clz
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- (i32.const 33)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- )
- )
- (set_local $$92
- (i32.shr_s
- (set_local $$91
- (i32.sub
- (i32.const 32)
- (get_local $$88)
- )
- )
- (i32.const 31)
- )
- )
- (set_local $$105
- (i32.shr_s
- (set_local $$95
- (i32.sub
- (get_local $$88)
- (i32.const 32)
- )
- )
- (i32.const 31)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$88)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.and
- (i32.shr_s
- (i32.sub
- (get_local $$91)
- (i32.const 1)
- )
- (i32.const 31)
- )
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$95)
- )
- )
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$91)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$88)
- )
- )
- (get_local $$105)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.and
- (get_local $$105)
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$88)
- )
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.and
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$89)
- )
- (get_local $$92)
- )
- )
- (set_local $$q_sroa_1_1_ph
- (i32.or
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$89)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$95)
- )
- )
- (get_local $$92)
- )
- (i32.and
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$91)
- )
- (i32.shr_s
- (i32.sub
- (get_local $$88)
- (i32.const 33)
- )
- (i32.const 31)
- )
- )
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.and
- (get_local $$66)
- (get_local $$n_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (if
- (i32.eq
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 1)
- )
- (block
- (set_local $$_0$1
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (set_local $$78
- (i32.ctz
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (set_local $$_0$1
- (i32.or
- (i32.const 0)
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$78)
- )
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.sub
- (i32.const 32)
- (get_local $$78)
- )
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$78)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- )
- )
- )
- (if
- (i32.eq
- (get_local $$sr_1_ph)
- (i32.const 0)
- )
- (block
- (set_local $$q_sroa_1_1_lcssa
- (get_local $$q_sroa_1_1_ph)
- )
- (set_local $$q_sroa_0_1_lcssa
- (get_local $$q_sroa_0_1_ph)
- )
- (set_local $$r_sroa_1_1_lcssa
- (get_local $$r_sroa_1_1_ph)
- )
- (set_local $$r_sroa_0_1_lcssa
- (get_local $$r_sroa_0_1_ph)
- )
- (set_local $$carry_0_lcssa$1
- (i32.const 0)
- )
- (set_local $$carry_0_lcssa$0
- (i32.const 0)
- )
- )
- (block
- (set_local $$d_sroa_0_0_insert_insert99$0
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$b$0)
- (i32.const -1)
- )
- )
- )
- (set_local $$d_sroa_0_0_insert_insert99$1
- (i32.or
- (get_local $$d_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$b$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$137$0
- (call $_i64Add
- (get_local $$d_sroa_0_0_insert_insert99$0)
- (get_local $$d_sroa_0_0_insert_insert99$1)
- (i32.const -1)
- (i32.const -1)
- )
- )
- (set_local $$137$1
- (i32.load
- (i32.const 168)
- )
- )
- (set_local $$q_sroa_1_1198
- (get_local $$q_sroa_1_1_ph)
- )
- (set_local $$q_sroa_0_1199
- (get_local $$q_sroa_0_1_ph)
- )
- (set_local $$r_sroa_1_1200
- (get_local $$r_sroa_1_1_ph)
- )
- (set_local $$r_sroa_0_1201
- (get_local $$r_sroa_0_1_ph)
- )
- (set_local $$sr_1202
- (get_local $$sr_1_ph)
- )
- (set_local $$carry_0203
- (i32.const 0)
+ (set_local $y64
+ (i64.or
+ (i64.extend_u/i32
+ (get_local $$b$0)
)
- (loop $while-out$2 $while-in$3
- (set_local $$147
- (i32.or
- (i32.shr_u
- (get_local $$q_sroa_0_1199)
- (i32.const 31)
- )
- (i32.shl
- (get_local $$q_sroa_1_1198)
- (i32.const 1)
- )
- )
- )
- (set_local $$149
- (i32.or
- (get_local $$carry_0203)
- (i32.shl
- (get_local $$q_sroa_0_1199)
- (i32.const 1)
- )
- )
- )
- (set_local $$r_sroa_0_0_insert_insert42$0
- (i32.or
- (i32.const 0)
- (i32.or
- (i32.shl
- (get_local $$r_sroa_0_1201)
- (i32.const 1)
- )
- (i32.shr_u
- (get_local $$q_sroa_1_1198)
- (i32.const 31)
- )
- )
- )
- )
- (set_local $$r_sroa_0_0_insert_insert42$1
- (i32.or
- (i32.shr_u
- (get_local $$r_sroa_0_1201)
- (i32.const 31)
- )
- (i32.shl
- (get_local $$r_sroa_1_1200)
- (i32.const 1)
- )
- )
- )
- (call $_i64Subtract
- (get_local $$137$0)
- (get_local $$137$1)
- (get_local $$r_sroa_0_0_insert_insert42$0)
- (get_local $$r_sroa_0_0_insert_insert42$1)
- )
- (set_local $$152
- (i32.and
- (set_local $$151$0
- (i32.or
- (i32.shr_s
- (set_local $$150$1
- (i32.load
- (i32.const 168)
- )
- )
- (i32.const 31)
- )
- (i32.shl
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 1)
- )
- )
- )
- (i32.const 1)
- )
- )
- (set_local $$r_sroa_0_0_extract_trunc
- (set_local $$154$0
- (call $_i64Subtract
- (get_local $$r_sroa_0_0_insert_insert42$0)
- (get_local $$r_sroa_0_0_insert_insert42$1)
- (i32.and
- (get_local $$151$0)
- (get_local $$d_sroa_0_0_insert_insert99$0)
- )
- (i32.and
- (i32.or
- (i32.shr_s
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 31)
- )
- (i32.shl
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_0_0_insert_insert99$1)
- )
- )
- )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_local $$b$1)
)
- (set_local $$r_sroa_1_4_extract_trunc
- (i32.load
- (i32.const 168)
- )
- )
- (if
- (i32.eq
- (set_local $$155
- (i32.sub
- (get_local $$sr_1202)
- (i32.const 1)
- )
- )
- (i32.const 0)
- )
- (br $while-out$2)
- (block
- (set_local $$q_sroa_1_1198
- (get_local $$147)
- )
- (set_local $$q_sroa_0_1199
- (get_local $$149)
- )
- (set_local $$r_sroa_1_1200
- (get_local $$r_sroa_1_4_extract_trunc)
- )
- (set_local $$r_sroa_0_1201
- (get_local $$r_sroa_0_0_extract_trunc)
- )
- (set_local $$sr_1202
- (get_local $$155)
- )
- (set_local $$carry_0203
- (get_local $$152)
- )
- )
- )
- (br $while-in$3)
- )
- (set_local $$q_sroa_1_1_lcssa
- (get_local $$147)
- )
- (set_local $$q_sroa_0_1_lcssa
- (get_local $$149)
- )
- (set_local $$r_sroa_1_1_lcssa
- (get_local $$r_sroa_1_4_extract_trunc)
+ (i64.const 32)
)
- (set_local $$r_sroa_0_1_lcssa
- (get_local $$r_sroa_0_0_extract_trunc)
- )
- (set_local $$carry_0_lcssa$1
- (i32.const 0)
- )
- (set_local $$carry_0_lcssa$0
- (get_local $$152)
- )
- )
- )
- (set_local $$q_sroa_0_0_insert_ext75$0
- (get_local $$q_sroa_0_1_lcssa)
- )
- (set_local $$q_sroa_0_0_insert_ext75$1
- (i32.const 0)
- )
- (set_local $$q_sroa_0_0_insert_insert77$1
- (i32.or
- (get_local $$q_sroa_1_1_lcssa)
- (get_local $$q_sroa_0_0_insert_ext75$1)
)
)
(if
- (i32.ne
+ (get_local $$rem)
+ (i64.store
(get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (get_local $$r_sroa_0_1_lcssa)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (get_local $$r_sroa_1_1_lcssa)
+ (i64.rem_u
+ (get_local $x64)
+ (get_local $y64)
)
)
)
- (set_local $$_0$1
- (i32.or
- (i32.or
- (i32.or
- (i32.shr_u
- (i32.or
- (i32.const 0)
- (get_local $$q_sroa_0_0_insert_ext75$0)
- )
- (i32.const 31)
- )
- (i32.shl
- (get_local $$q_sroa_0_0_insert_insert77$1)
- (i32.const 1)
- )
- )
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$q_sroa_0_0_insert_ext75$1)
- (i32.const 1)
- )
- (i32.shr_u
- (get_local $$q_sroa_0_0_insert_ext75$0)
- (i32.const 31)
- )
- )
- (i32.const 0)
- )
- )
- (get_local $$carry_0_lcssa$1)
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$q_sroa_0_0_insert_ext75$0)
- (i32.const 1)
- )
- (i32.shr_u
- (i32.const 0)
- (i32.const 31)
+ (i32.store
+ (i32.const 168)
+ (i32.wrap/i64
+ (i64.shr_u
+ (set_local $x64
+ (i64.div_u
+ (get_local $x64)
+ (get_local $y64)
)
)
- (i32.const -2)
+ (i64.const 32)
)
- (get_local $$carry_0_lcssa$0)
)
)
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
+ (i32.wrap/i64
+ (get_local $x64)
)
)
(func $dynCall_ii (param $index i32) (param $a1 i32) (result i32)
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 52c1444b6..ec2f98964 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -48,6 +48,7 @@
(export "dynCall_ii" $dynCall_ii)
(export "dynCall_iiii" $dynCall_iiii)
(export "dynCall_vi" $dynCall_vi)
+ (export "___udivmoddi4" $___udivmoddi4)
(table $b0 $___stdio_close $b1 $b1 $___stdout_write $___stdio_seek $___stdio_write $b1 $b1 $b1 $b2 $b2 $b2 $b2 $b2 $_cleanup $b2 $b2)
(func $stackAlloc (param $size i32) (result i32)
(local $ret i32)
@@ -29144,1209 +29145,60 @@
)
)
(func $___udivmoddi4 (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (param $$rem i32) (result i32)
- (local $$_0$1 i32)
- (local $$_0$0 i32)
- (local $$n_sroa_1_4_extract_trunc i32)
- (local $$n_sroa_0_0_extract_trunc i32)
- (local $$d_sroa_0_0_extract_trunc i32)
- (local $$d_sroa_1_4_extract_trunc i32)
- (local $$88 i32)
- (local $$sr_1_ph i32)
- (local $$r_sroa_1_1_ph i32)
- (local $$r_sroa_0_1_ph i32)
- (local $$q_sroa_1_1_ph i32)
- (local $$q_sroa_0_1_ph i32)
- (local $$r_sroa_0_1201 i32)
- (local $$q_sroa_1_1198 i32)
- (local $$q_sroa_0_1199 i32)
- (local $$q_sroa_0_0_insert_ext75$0 i32)
- (local $$n_sroa_1_4_extract_shift$0 i32)
- (local $$91 i32)
- (local $$78 i32)
- (local $$57 i32)
- (local $$150$1 i32)
- (local $$125 i32)
- (local $$119 i32)
- (local $$sr_1202 i32)
- (local $$r_sroa_1_4_extract_trunc i32)
- (local $$r_sroa_1_1_lcssa i32)
- (local $$r_sroa_1_1200 i32)
- (local $$r_sroa_0_1_lcssa i32)
- (local $$r_sroa_0_0_insert_insert42$1 i32)
- (local $$r_sroa_0_0_insert_insert42$0 i32)
- (local $$r_sroa_0_0_extract_trunc i32)
- (local $$q_sroa_1_1_lcssa i32)
- (local $$q_sroa_0_1_lcssa i32)
- (local $$q_sroa_0_0_insert_ext75$1 i32)
- (local $$d_sroa_0_0_insert_insert99$1 i32)
- (local $$d_sroa_0_0_insert_insert99$0 i32)
- (local $$carry_0_lcssa$1 i32)
- (local $$carry_0_lcssa$0 i32)
- (local $$carry_0203 i32)
- (local $$95 i32)
- (local $$92 i32)
- (local $$89 i32)
- (local $$58 i32)
- (local $$51 i32)
- (local $$4 i32)
- (local $$17 i32)
- (local $$152 i32)
- (local $$149 i32)
- (local $$147 i32)
- (local $$130 i32)
- (local $$126 i32)
- (local $$105 i32)
- (local $$q_sroa_0_0_insert_insert77$1 i32)
- (local $$d_sroa_1_4_extract_shift$0 i32)
- (local $$66 i32)
- (local $$37 i32)
- (local $$155 i32)
- (local $$151$0 i32)
- (local $$137$1 i32)
- (local $$137$0 i32)
- (local $$86 i32)
- (local $$49 i32)
- (local $$154$0 i32)
- (local $$117 i32)
- (set_local $$n_sroa_0_0_extract_trunc
- (get_local $$a$0)
- )
- (set_local $$n_sroa_1_4_extract_trunc
- (set_local $$n_sroa_1_4_extract_shift$0
- (get_local $$a$1)
- )
- )
- (set_local $$d_sroa_0_0_extract_trunc
- (get_local $$b$0)
- )
- (set_local $$d_sroa_1_4_extract_trunc
- (set_local $$d_sroa_1_4_extract_shift$0
- (get_local $$b$1)
- )
- )
- (if
- (i32.eq
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- (block
- (set_local $$4
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
+ (local $x64 i64)
+ (local $y64 i64)
+ (set_local $x64
+ (i64.or
+ (i64.extend_u/i32
+ (get_local $$a$0)
)
- (if
- (i32.eq
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (get_local $$4)
- (block
- (i32.store
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (if
- (i32.eqz
- (get_local $$4)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_local $$a$1)
)
+ (i64.const 32)
)
)
)
- (set_local $$17
- (i32.eq
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 0)
- )
- )
- (block $do-once$0
- (if
- (i32.eq
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (get_local $$17)
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.eq
- (get_local $$n_sroa_0_0_extract_trunc)
- (i32.const 0)
- )
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.const 0)
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.rem_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.div_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.eq
- (i32.and
- (set_local $$37
- (i32.sub
- (get_local $$d_sroa_1_4_extract_trunc)
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- (i32.const 0)
- )
- (block
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (i32.and
- (get_local $$37)
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.ctz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.le_u
- (set_local $$51
- (i32.sub
- (set_local $$49
- (i32.clz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- (i32.const 30)
- )
- (block
- (set_local $$57
- (i32.add
- (get_local $$51)
- (i32.const 1)
- )
- )
- (set_local $$58
- (i32.sub
- (i32.const 31)
- (get_local $$51)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$57)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$58)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$57)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$57)
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.const 0)
- )
- (set_local $$q_sroa_1_1_ph
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$58)
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.eq
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (if
- (i32.eqz
- (get_local $$17)
- )
- (block
- (if
- (i32.le_u
- (set_local $$119
- (i32.sub
- (set_local $$117
- (i32.clz
- (get_local $$d_sroa_1_4_extract_trunc)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- (i32.const 31)
- )
- (block
- (set_local $$125
- (i32.add
- (get_local $$119)
- (i32.const 1)
- )
- )
- (set_local $$126
- (i32.sub
- (i32.const 31)
- (get_local $$119)
- )
- )
- (set_local $$130
- (i32.shr_s
- (i32.sub
- (get_local $$119)
- (i32.const 31)
- )
- (i32.const 31)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$125)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.and
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$125)
- )
- (get_local $$130)
- )
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$126)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.and
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$125)
- )
- (get_local $$130)
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.const 0)
- )
- (set_local $$q_sroa_1_1_ph
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$126)
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.eq
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$1
- (i32.const 0)
- )
- (set_local $$_0$0
- (i32.const 0)
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- (if
- (i32.ne
- (i32.and
- (set_local $$66
- (i32.sub
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- (i32.const 0)
- )
- (block
- (set_local $$89
- (i32.sub
- (i32.const 64)
- (set_local $$88
- (i32.sub
- (set_local $$86
- (i32.add
- (i32.clz
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- (i32.const 33)
- )
- )
- (i32.clz
- (get_local $$n_sroa_1_4_extract_trunc)
- )
- )
- )
- )
- )
- (set_local $$92
- (i32.shr_s
- (set_local $$91
- (i32.sub
- (i32.const 32)
- (get_local $$88)
- )
- )
- (i32.const 31)
- )
- )
- (set_local $$105
- (i32.shr_s
- (set_local $$95
- (i32.sub
- (get_local $$88)
- (i32.const 32)
- )
- )
- (i32.const 31)
- )
- )
- (set_local $$sr_1_ph
- (get_local $$88)
- )
- (set_local $$r_sroa_0_1_ph
- (i32.or
- (i32.and
- (i32.shr_s
- (i32.sub
- (get_local $$91)
- (i32.const 1)
- )
- (i32.const 31)
- )
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$95)
- )
- )
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$91)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$88)
- )
- )
- (get_local $$105)
- )
- )
- )
- (set_local $$r_sroa_1_1_ph
- (i32.and
- (get_local $$105)
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$88)
- )
- )
- )
- (set_local $$q_sroa_0_1_ph
- (i32.and
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$89)
- )
- (get_local $$92)
- )
- )
- (set_local $$q_sroa_1_1_ph
- (i32.or
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$89)
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$95)
- )
- )
- (get_local $$92)
- )
- (i32.and
- (i32.shl
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$91)
- )
- (i32.shr_s
- (i32.sub
- (get_local $$88)
- (i32.const 33)
- )
- (i32.const 31)
- )
- )
- )
- )
- (br $do-once$0)
- )
- )
- (if
- (i32.ne
- (get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.and
- (get_local $$66)
- (get_local $$n_sroa_0_0_extract_trunc)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (i32.const 0)
- )
- )
- )
- (if
- (i32.eq
- (get_local $$d_sroa_0_0_extract_trunc)
- (i32.const 1)
- )
- (block
- (set_local $$_0$1
- (i32.or
- (get_local $$n_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$a$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$a$0)
- (i32.const -1)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- (block
- (set_local $$78
- (i32.ctz
- (get_local $$d_sroa_0_0_extract_trunc)
- )
- )
- (set_local $$_0$1
- (i32.or
- (i32.const 0)
- (i32.shr_u
- (get_local $$n_sroa_1_4_extract_trunc)
- (get_local $$78)
- )
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.shl
- (get_local $$n_sroa_1_4_extract_trunc)
- (i32.sub
- (i32.const 32)
- (get_local $$78)
- )
- )
- (i32.shr_u
- (get_local $$n_sroa_0_0_extract_trunc)
- (get_local $$78)
- )
- )
- )
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
- )
- )
- )
- )
- )
- )
- (if
- (i32.eq
- (get_local $$sr_1_ph)
- (i32.const 0)
- )
- (block
- (set_local $$q_sroa_1_1_lcssa
- (get_local $$q_sroa_1_1_ph)
- )
- (set_local $$q_sroa_0_1_lcssa
- (get_local $$q_sroa_0_1_ph)
- )
- (set_local $$r_sroa_1_1_lcssa
- (get_local $$r_sroa_1_1_ph)
- )
- (set_local $$r_sroa_0_1_lcssa
- (get_local $$r_sroa_0_1_ph)
- )
- (set_local $$carry_0_lcssa$1
- (i32.const 0)
- )
- (set_local $$carry_0_lcssa$0
- (i32.const 0)
- )
- )
- (block
- (set_local $$d_sroa_0_0_insert_insert99$0
- (i32.or
- (i32.const 0)
- (i32.and
- (get_local $$b$0)
- (i32.const -1)
- )
- )
- )
- (set_local $$d_sroa_0_0_insert_insert99$1
- (i32.or
- (get_local $$d_sroa_1_4_extract_shift$0)
- (i32.and
- (get_local $$b$1)
- (i32.const 0)
- )
- )
- )
- (set_local $$137$0
- (call $_i64Add
- (get_local $$d_sroa_0_0_insert_insert99$0)
- (get_local $$d_sroa_0_0_insert_insert99$1)
- (i32.const -1)
- (i32.const -1)
- )
- )
- (set_local $$137$1
- (i32.load
- (i32.const 168)
- )
- )
- (set_local $$q_sroa_1_1198
- (get_local $$q_sroa_1_1_ph)
- )
- (set_local $$q_sroa_0_1199
- (get_local $$q_sroa_0_1_ph)
- )
- (set_local $$r_sroa_1_1200
- (get_local $$r_sroa_1_1_ph)
- )
- (set_local $$r_sroa_0_1201
- (get_local $$r_sroa_0_1_ph)
- )
- (set_local $$sr_1202
- (get_local $$sr_1_ph)
- )
- (set_local $$carry_0203
- (i32.const 0)
+ (set_local $y64
+ (i64.or
+ (i64.extend_u/i32
+ (get_local $$b$0)
)
- (loop $while-out$2 $while-in$3
- (set_local $$147
- (i32.or
- (i32.shr_u
- (get_local $$q_sroa_0_1199)
- (i32.const 31)
- )
- (i32.shl
- (get_local $$q_sroa_1_1198)
- (i32.const 1)
- )
- )
- )
- (set_local $$149
- (i32.or
- (get_local $$carry_0203)
- (i32.shl
- (get_local $$q_sroa_0_1199)
- (i32.const 1)
- )
- )
- )
- (set_local $$r_sroa_0_0_insert_insert42$0
- (i32.or
- (i32.const 0)
- (i32.or
- (i32.shl
- (get_local $$r_sroa_0_1201)
- (i32.const 1)
- )
- (i32.shr_u
- (get_local $$q_sroa_1_1198)
- (i32.const 31)
- )
- )
- )
- )
- (set_local $$r_sroa_0_0_insert_insert42$1
- (i32.or
- (i32.shr_u
- (get_local $$r_sroa_0_1201)
- (i32.const 31)
- )
- (i32.shl
- (get_local $$r_sroa_1_1200)
- (i32.const 1)
- )
- )
- )
- (call $_i64Subtract
- (get_local $$137$0)
- (get_local $$137$1)
- (get_local $$r_sroa_0_0_insert_insert42$0)
- (get_local $$r_sroa_0_0_insert_insert42$1)
- )
- (set_local $$152
- (i32.and
- (set_local $$151$0
- (i32.or
- (i32.shr_s
- (set_local $$150$1
- (i32.load
- (i32.const 168)
- )
- )
- (i32.const 31)
- )
- (i32.shl
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 1)
- )
- )
- )
- (i32.const 1)
- )
- )
- (set_local $$r_sroa_0_0_extract_trunc
- (set_local $$154$0
- (call $_i64Subtract
- (get_local $$r_sroa_0_0_insert_insert42$0)
- (get_local $$r_sroa_0_0_insert_insert42$1)
- (i32.and
- (get_local $$151$0)
- (get_local $$d_sroa_0_0_insert_insert99$0)
- )
- (i32.and
- (i32.or
- (i32.shr_s
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 31)
- )
- (i32.shl
- (if
- (i32.lt_s
- (get_local $$150$1)
- (i32.const 0)
- )
- (i32.const -1)
- (i32.const 0)
- )
- (i32.const 1)
- )
- )
- (get_local $$d_sroa_0_0_insert_insert99$1)
- )
- )
- )
+ (i64.shl
+ (i64.extend_u/i32
+ (get_local $$b$1)
)
- (set_local $$r_sroa_1_4_extract_trunc
- (i32.load
- (i32.const 168)
- )
- )
- (if
- (i32.eq
- (set_local $$155
- (i32.sub
- (get_local $$sr_1202)
- (i32.const 1)
- )
- )
- (i32.const 0)
- )
- (br $while-out$2)
- (block
- (set_local $$q_sroa_1_1198
- (get_local $$147)
- )
- (set_local $$q_sroa_0_1199
- (get_local $$149)
- )
- (set_local $$r_sroa_1_1200
- (get_local $$r_sroa_1_4_extract_trunc)
- )
- (set_local $$r_sroa_0_1201
- (get_local $$r_sroa_0_0_extract_trunc)
- )
- (set_local $$sr_1202
- (get_local $$155)
- )
- (set_local $$carry_0203
- (get_local $$152)
- )
- )
- )
- (br $while-in$3)
- )
- (set_local $$q_sroa_1_1_lcssa
- (get_local $$147)
- )
- (set_local $$q_sroa_0_1_lcssa
- (get_local $$149)
- )
- (set_local $$r_sroa_1_1_lcssa
- (get_local $$r_sroa_1_4_extract_trunc)
+ (i64.const 32)
)
- (set_local $$r_sroa_0_1_lcssa
- (get_local $$r_sroa_0_0_extract_trunc)
- )
- (set_local $$carry_0_lcssa$1
- (i32.const 0)
- )
- (set_local $$carry_0_lcssa$0
- (get_local $$152)
- )
- )
- )
- (set_local $$q_sroa_0_0_insert_ext75$0
- (get_local $$q_sroa_0_1_lcssa)
- )
- (set_local $$q_sroa_0_0_insert_ext75$1
- (i32.const 0)
- )
- (set_local $$q_sroa_0_0_insert_insert77$1
- (i32.or
- (get_local $$q_sroa_1_1_lcssa)
- (get_local $$q_sroa_0_0_insert_ext75$1)
)
)
(if
- (i32.ne
+ (get_local $$rem)
+ (i64.store
(get_local $$rem)
- (i32.const 0)
- )
- (block
- (i32.store
- (get_local $$rem)
- (i32.or
- (i32.const 0)
- (get_local $$r_sroa_0_1_lcssa)
- )
- )
- (i32.store offset=4
- (get_local $$rem)
- (get_local $$r_sroa_1_1_lcssa)
+ (i64.rem_u
+ (get_local $x64)
+ (get_local $y64)
)
)
)
- (set_local $$_0$1
- (i32.or
- (i32.or
- (i32.or
- (i32.shr_u
- (i32.or
- (i32.const 0)
- (get_local $$q_sroa_0_0_insert_ext75$0)
- )
- (i32.const 31)
- )
- (i32.shl
- (get_local $$q_sroa_0_0_insert_insert77$1)
- (i32.const 1)
- )
- )
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$q_sroa_0_0_insert_ext75$1)
- (i32.const 1)
- )
- (i32.shr_u
- (get_local $$q_sroa_0_0_insert_ext75$0)
- (i32.const 31)
- )
- )
- (i32.const 0)
- )
- )
- (get_local $$carry_0_lcssa$1)
- )
- )
- (set_local $$_0$0
- (i32.or
- (i32.and
- (i32.or
- (i32.shl
- (get_local $$q_sroa_0_0_insert_ext75$0)
- (i32.const 1)
- )
- (i32.shr_u
- (i32.const 0)
- (i32.const 31)
+ (i32.store
+ (i32.const 168)
+ (i32.wrap/i64
+ (i64.shr_u
+ (set_local $x64
+ (i64.div_u
+ (get_local $x64)
+ (get_local $y64)
)
)
- (i32.const -2)
+ (i64.const 32)
)
- (get_local $$carry_0_lcssa$0)
)
)
- (return
- (block
- (i32.store
- (i32.const 168)
- (get_local $$_0$1)
- )
- (get_local $$_0$0)
- )
+ (i32.wrap/i64
+ (get_local $x64)
)
)
(func $dynCall_ii (param $index i32) (param $a1 i32) (result i32)