Skip to content

Commit

Permalink
[wasm] Fix WasmBase.IsSupported in AOT (#88523)
Browse files Browse the repository at this point in the history
Add `WasmBase` to `supported_wasm_intrinsics group`. That way we handle the `WasmBase`
correctly when SIMD is enabled (default case). Before this change the `emit_hardware_intrinsics`
returned false for the `WasmBase.IsSupported`, because it wasn't in the group and we are using
it for the whole `S.R.I.Wasm` namespace.

Example of the emitted code difference to confirm the fix:

    (func corlib_ulong_Log2_ulong(param i64, i32) (result i64)) code size difference: -30 bytes
    ...
       local.get $0
       i64.const
    -  i64.shr.u
    -  i32.wrap.i64
    -  local.tee $1
    -  i32.eqz
    +  i64.or
    +  i64.clz
    +  i64.const
    +  i64.xor
    -  if
    -   local.get $0
    -   i32.wrap.i64
    -   i32.const
    -   i32.or
    -   local.get $1
    -   call corlib_System_Numerics_BitOperations_Log2SoftwareFallback_uint
    -   i64.extend.i32.u
    -   return
    -
    -  local.get $1
    -  i32.const
    -  i32.or
    -  local.get $1
    -  call corlib_System_Numerics_BitOperations_Log2SoftwareFallback_uint
    -  i32.const
    -  i32.add
    -  i64.extend.i32.u
  • Loading branch information
radekdoulik authored Jul 7, 2023
1 parent ff57624 commit fc9cbfc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -5336,6 +5336,7 @@ static SimdIntrinsic packedsimd_methods [] = {

static const IntrinGroup supported_wasm_intrinsics [] = {
{ "PackedSimd", MONO_CPU_WASM_SIMD, packedsimd_methods, sizeof (packedsimd_methods) },
{ "WasmBase", MONO_CPU_WASM_BASE, wasmbase_methods, sizeof (wasmbase_methods) },
};

static const IntrinGroup supported_wasm_common_intrinsics [] = {
Expand Down

0 comments on commit fc9cbfc

Please sign in to comment.