summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-07 16:36:53 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-12-07 16:36:53 -0800
commit9cf484e68a8c200f997f001ce111c92bc3b970a7 (patch)
tree94706a40b3ba5aadd93e4306880fecad9bcdf781
parentfc46fce89fe13dbc10596efbdc5ca92ff3cc8229 (diff)
downloadbinaryen-9cf484e68a8c200f997f001ce111c92bc3b970a7.tar.gz
binaryen-9cf484e68a8c200f997f001ce111c92bc3b970a7.tar.bz2
binaryen-9cf484e68a8c200f997f001ce111c92bc3b970a7.zip
fix double eq and ne
-rw-r--r--src/wasm2asm.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index faa49be5e..74d905252 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -947,8 +947,20 @@ Ref Wasm2AsmBuilder::processFunctionBody(Expression* curr, IString result) {
case Div: ret = ValueBuilder::makeBinary(left, DIV, right); break;
case Min: ret = ValueBuilder::makeCall(MATH_MIN, left, right); break;
case Max: ret = ValueBuilder::makeCall(MATH_MAX, left, right); break;
- case Eq: return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), EQ, makeSigning(right, ASM_SIGNED));
- case Ne: return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), NE, makeSigning(right, ASM_SIGNED));
+ case Eq: {
+ if (curr->left->type == i32) {
+ return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), EQ, makeSigning(right, ASM_SIGNED));
+ } else {
+ return ValueBuilder::makeBinary(left, EQ, right);
+ }
+ }
+ case Ne: {
+ if (curr->left->type == i32) {
+ return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), NE, makeSigning(right, ASM_SIGNED));
+ } else {
+ return ValueBuilder::makeBinary(left, NE, right);
+ }
+ }
case LtS: return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), LT, makeSigning(right, ASM_SIGNED));
case LtU: return ValueBuilder::makeBinary(makeSigning(left, ASM_UNSIGNED), LT, makeSigning(right, ASM_UNSIGNED));
case LeS: return ValueBuilder::makeBinary(makeSigning(left, ASM_SIGNED), LE, makeSigning(right, ASM_SIGNED));