From a2d388b5931edef0f3e95b163d590e25a8f042e4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 9 Mar 2020 11:25:29 -0700 Subject: [PATCH] Fix types of SIMD or, xor, and The operands of these bitwise instructions could have different types and still be valid Wasm (i.e. `v128`). Because of this, we must tell Cranelift to cast both operands to the same type--the default type, in this case. This undoes the work merged in https://github.com/bytecodealliance/cranelift/pull/1233. --- cranelift/wasm/src/code_translator.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 06fc5126c3..ddc19a9b05 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -864,15 +864,15 @@ pub fn translate_operator( let (arg1, arg2) = state.pop2(); state.push1(builder.ins().iadd(arg1, arg2)); } - Operator::I32And | Operator::I64And | Operator::V128And => { + Operator::I32And | Operator::I64And => { let (arg1, arg2) = state.pop2(); state.push1(builder.ins().band(arg1, arg2)); } - Operator::I32Or | Operator::I64Or | Operator::V128Or => { + Operator::I32Or | Operator::I64Or => { let (arg1, arg2) = state.pop2(); state.push1(builder.ins().bor(arg1, arg2)); } - Operator::I32Xor | Operator::I64Xor | Operator::V128Xor => { + Operator::I32Xor | Operator::I64Xor => { let (arg1, arg2) = state.pop2(); state.push1(builder.ins().bxor(arg1, arg2)); } @@ -1331,6 +1331,18 @@ pub fn translate_operator( let (a, b) = pop2_with_bitcast(state, type_of(op), builder); state.push1(builder.ins().imul(a, b)) } + Operator::V128Or => { + let (a, b) = pop2_with_bitcast(state, type_of(op), builder); + state.push1(builder.ins().bor(a, b)) + } + Operator::V128Xor => { + let (a, b) = pop2_with_bitcast(state, type_of(op), builder); + state.push1(builder.ins().bxor(a, b)) + } + Operator::V128And => { + let (a, b) = pop2_with_bitcast(state, type_of(op), builder); + state.push1(builder.ins().band(a, b)) + } Operator::V128AndNot => { let (a, b) = pop2_with_bitcast(state, type_of(op), builder); state.push1(builder.ins().band_not(a, b))