From 4f542922b1b42536be31f6c1987b976f39a921b7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 7 Dec 2015 16:39:09 -0800 Subject: fix double mul --- src/wasm2asm.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 74d905252..d0c79097f 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -933,7 +933,13 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) { switch (curr->op) { case Add: ret = ValueBuilder::makeBinary(left, PLUS, right); break; case Sub: ret = ValueBuilder::makeBinary(left, MINUS, right); break; - case Mul: return ValueBuilder::makeCall(MATH_IMUL, left, right); // TODO: when one operand is a small int, emit a multiply + case Mul: { + if (curr->type == i32) { + return ValueBuilder::makeCall(MATH_IMUL, left, right); // TODO: when one operand is a small int, emit a multiply + } else { + return ValueBuilder::makeBinary(left, MINUS, right); break; + } + } case DivS: ret = ValueBuilder::makeBinary(left, DIV, right); break; case DivU: ret = ValueBuilder::makeBinary(left, DIV, right); break; case RemS: ret = ValueBuilder::makeBinary(left, MOD, right); break; -- cgit v1.2.3