Skip to content

Commit

Permalink
Ensure that the handling for the V128_BITCAST APIs is correctly perfo…
Browse files Browse the repository at this point in the history
…rmant on Mono WASM (#105009)
  • Loading branch information
tannergooding authored Jul 17, 2024
1 parent e5e56df commit bc45b3e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
7 changes: 0 additions & 7 deletions src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3652,13 +3652,6 @@ function emit_simd_2 (builder: WasmBuilder, ip: MintOpcodePtr, index: SimdIntrin
}

switch (index) {
case SimdIntrinsic2.V128_BITCAST: {
// BitCast is a no-op and so we just load the value and return it "as is"
append_ldloc(builder, getArgU16(ip, 2), WasmOpcode.PREFIX_simd, WasmSimdOpcode.v128_load);
append_simd_store(builder, ip);
return true;
}

case SimdIntrinsic2.V128_I1_CREATE_SCALAR:
case SimdIntrinsic2.V128_I2_CREATE_SCALAR:
case SimdIntrinsic2.V128_I4_CREATE_SCALAR:
Expand Down
2 changes: 0 additions & 2 deletions src/mono/mono/mini/interp/interp-simd-intrins.def
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_MULTIPLY, interp_v128_

INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_DIVISION, interp_v128_r4_op_division, 231)

INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_BITCAST, interp_v128_bitcast, -1)

INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I1_NEGATION, interp_v128_i1_op_negation, 97)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I2_NEGATION, interp_v128_i2_op_negation, 129)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I4_NEGATION, interp_v128_i4_op_negation, 161)
Expand Down
7 changes: 0 additions & 7 deletions src/mono/mono/mini/interp/interp-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ interp_v128_i4_all_bits_set (gpointer res)
memset (res, 0xff, SIZEOF_V128);
}

// Vector128<TTo> As<TFrom, TTo>(Vector128<TFrom> v1)
static void
interp_v128_bitcast (gpointer res, gpointer v1)
{
*(v128_i1*)res = *(v128_i1*)v1;
}

// op_Addition
static void
interp_v128_i1_op_addition (gpointer res, gpointer v1, gpointer v2)
Expand Down
22 changes: 12 additions & 10 deletions src/mono/mono/mini/interp/transform-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,7 @@ emit_sri_vector128 (TransformData *td, MonoMethod *cmethod, MonoMethodSignature
case SN_AsSingle:
case SN_AsUInt16:
case SN_AsUInt32:
case SN_AsUInt64: {
if (!is_element_type_primitive (csignature->ret) || !is_element_type_primitive (csignature->params [0]))
return FALSE;
simd_opcode = MINT_SIMD_INTRINS_P_P;
simd_intrins = INTERP_SIMD_INTRINSIC_V128_BITCAST;
break;
}
case SN_AsUInt64:
case SN_AsVector:
case SN_AsVector128:
case SN_AsVector4: {
Expand All @@ -480,10 +474,18 @@ emit_sri_vector128 (TransformData *td, MonoMethod *cmethod, MonoMethodSignature
MonoClass *arg_class = mono_class_from_mono_type_internal (csignature->params [0]);
int arg_size = mono_class_value_size (arg_class, NULL);

vector_klass = ret_class;
vector_size = ret_size;

if (arg_size == ret_size) {
simd_opcode = MINT_SIMD_INTRINS_P_P;
simd_intrins = INTERP_SIMD_INTRINSIC_V128_BITCAST;
break;
td->sp--;
interp_add_ins (td, MINT_MOV_VT);
interp_ins_set_sreg (td->last_ins, td->sp [0].var);
push_type_vt (td, vector_klass, vector_size);
interp_ins_set_dreg (td->last_ins, td->sp [-1].var);
td->last_ins->data [0] = GINT32_TO_UINT16 (vector_size);
td->ip += 5;
return TRUE;
}
return FALSE;
}
Expand Down

0 comments on commit bc45b3e

Please sign in to comment.