Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float splat with immediate in JIT #303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/jit/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ struct JITArg {

void set(Operand* operand);

static bool isImm(Operand* operand)
{
return VARIABLE_TYPE(*operand) == Instruction::ConstPtr;
}

sljit_s32 arg;
sljit_sw argw;
};
Expand Down
10 changes: 10 additions & 0 deletions src/jit/SimdInl.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ static void emitSplatSIMD(sljit_compiler* compiler, Instruction* instr)
default:
ASSERT(instr->opcode() == ByteCode::F64X2SplatOpcode);
type = SLJIT_SIMD_REG_128 | SLJIT_SIMD_ELEM_64 | SLJIT_SIMD_FLOAT;
#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
if (JITArg::isImm(operands)) {
type = SLJIT_SIMD_REG_128 | SLJIT_SIMD_ELEM_64;
}
#endif /* SLJIT_32BIT_ARCHITECTURE */
break;
}

Expand All @@ -241,6 +246,11 @@ static void emitSplatSIMD(sljit_compiler* compiler, Instruction* instr)
} else {
#endif /* SLJIT_32BIT_ARCHITECTURE */
args[0].set(operands);

if (SLJIT_IS_IMM(args[0].arg)) {
type &= ~SLJIT_SIMD_FLOAT;
}

sljit_emit_simd_replicate(compiler, type, dstReg, args[0].arg, args[0].argw);
#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
}
Expand Down
16 changes: 16 additions & 0 deletions test/jit/splat.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(module
(table $t 10 externref)

(func (export "splat_f32") (result v128)
f32.const 1234.75
f32x4.splat
)

(func (export "splat_f64") (result v128)
f64.const -123456.75
f64x2.splat
)
)

(assert_return (invoke "splat_f32") (v128.const f32x4 1234.75 1234.75 1234.75 1234.75))
(assert_return (invoke "splat_f64") (v128.const f64x2 -123456.75 -123456.75))
Loading