From dac2c2774bb5a45150e7547609b4760ec6c8300a Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Tue, 21 Nov 2023 09:47:19 +0000 Subject: [PATCH] Re-enable float select Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- src/interpreter/ByteCode.h | 12 ++++++------ src/jit/IntMath32Inl.h | 6 ++++-- src/jit/IntMath64Inl.h | 6 ++++-- src/parser/WASMParser.cpp | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/interpreter/ByteCode.h b/src/interpreter/ByteCode.h index 8b436e261..c18cbe9bf 100644 --- a/src/interpreter/ByteCode.h +++ b/src/interpreter/ByteCode.h @@ -1132,10 +1132,11 @@ class JumpIfFalse : public ByteCode { class Select : public ByteCode { public: - Select(ByteCodeStackOffset condOffset, uint16_t size, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst) + Select(ByteCodeStackOffset condOffset, uint16_t size, bool isFloat, ByteCodeStackOffset src0, ByteCodeStackOffset src1, ByteCodeStackOffset dst) : ByteCode(Opcode::SelectOpcode) , m_condOffset(condOffset) , m_valueSize(size) + , m_isFloat(isFloat) , m_src0Offset(src0) , m_src1Offset(src1) , m_dstOffset(dst) @@ -1143,10 +1144,8 @@ class Select : public ByteCode { } ByteCodeStackOffset condOffset() const { return m_condOffset; } - uint16_t valueSize() const - { - return m_valueSize; - } + uint16_t valueSize() const { return m_valueSize; } + bool isFloat() const { return m_isFloat != 0; } ByteCodeStackOffset src0Offset() const { return m_src0Offset; } ByteCodeStackOffset src1Offset() const { return m_src1Offset; } ByteCodeStackOffset dstOffset() const { return m_dstOffset; } @@ -1164,7 +1163,8 @@ class Select : public ByteCode { protected: ByteCodeStackOffset m_condOffset; - uint16_t m_valueSize; + uint8_t m_valueSize; + uint8_t m_isFloat; ByteCodeStackOffset m_src0Offset; ByteCodeStackOffset m_src1Offset; ByteCodeStackOffset m_dstOffset; diff --git a/src/jit/IntMath32Inl.h b/src/jit/IntMath32Inl.h index 3fac9ad59..bad81d32d 100644 --- a/src/jit/IntMath32Inl.h +++ b/src/jit/IntMath32Inl.h @@ -860,11 +860,13 @@ void emitSelect(sljit_compiler* compiler, Instruction* instr, sljit_s32 type) JITArg cond; ASSERT(instr->opcode() == ByteCode::SelectOpcode && instr->paramCount() == 3); - if (false) { + Select* select = reinterpret_cast(instr->byteCode()); + + if (select->isFloat()) { return emitFloatSelect(compiler, instr, type); } - if (reinterpret_cast(instr->byteCode())->valueSize() == 4) { + if (select->valueSize() == 4) { JITArg args[3] = { operands, operands + 1, operands + 3 }; if (type == -1) { diff --git a/src/jit/IntMath64Inl.h b/src/jit/IntMath64Inl.h index 6f813fe18..756a34592 100644 --- a/src/jit/IntMath64Inl.h +++ b/src/jit/IntMath64Inl.h @@ -349,11 +349,13 @@ void emitSelect(sljit_compiler* compiler, Instruction* instr, sljit_s32 type) Operand* operands = instr->operands(); assert(instr->opcode() == ByteCode::SelectOpcode && instr->paramCount() == 3); - if (false) { + Select* select = reinterpret_cast(instr->byteCode()); + + if (select->isFloat()) { return emitFloatSelect(compiler, instr, type); } - bool is32 = reinterpret_cast(instr->byteCode())->valueSize() == 4; + bool is32 = select->valueSize() == 4; sljit_s32 movOpcode = is32 ? SLJIT_MOV32 : SLJIT_MOV; JITArg args[3] = { operands, operands + 1, operands + 3 }; diff --git a/src/parser/WASMParser.cpp b/src/parser/WASMParser.cpp index 0c71373bc..c18b5101b 100644 --- a/src/parser/WASMParser.cpp +++ b/src/parser/WASMParser.cpp @@ -1847,7 +1847,8 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate { auto src1 = popVMStack(); auto src0 = popVMStack(); auto dst = computeExprResultPosition(type); - pushByteCode(Walrus::Select(stackPos, Walrus::valueSize(type), src0, src1, dst), WASMOpcode::SelectOpcode); + bool isFloat = type == Walrus::Value::F32 || type == Walrus::Value::F64; + pushByteCode(Walrus::Select(stackPos, Walrus::valueSize(type), isFloat, src0, src1, dst), WASMOpcode::SelectOpcode); } virtual void OnThrowExpr(Index tagIndex) override