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

[wasm] Add Vector128.OnesComplement SIMD intrinsic #71384

Merged

Conversation

radekdoulik
Copy link
Member

@radekdoulik radekdoulik commented Jun 28, 2022

Add wasm specific implementation of Vector128.OnesComplement method.

Example compilation output. Managed:

static Vector128<double> SimdTest3(Vector128<double> input)
{
    return Vector128.OnesComplement(input);
}

IR:

BB3:                                              ; preds = %BB2
  %cast_to_4_x_i32 = bitcast <2 x double> %simd_vtype to <4 x i32>
  %wasm_not = xor <4 x i32> %cast_to_4_x_i32, <i32 -1, i32 -1, i32 -1, i32 -1>
  %cast_back = bitcast <4 x i32> %wasm_not to <2 x double>
  br label %BB4

wasm - Debug configuration:

(func Wasm_Console_V8_CJS_Sample_Test_SimdTest3_System_Runtime_Intrinsics_Vector128_1_double(param $0 i32, $1 i32, $2 i32))
 local $3 i32
 local $4 i32
 local $5 v128
 local $6 v128
 0x00cf955a: global.get $__stack_pointer
 0x00cf955c: local.set $3
 0x00cf955e: i32.const 16
 0x00cf9560: local.set $4
 0x00cf9562: local.get $3
 0x00cf9564: local.get $4
 0x00cf9566: i32.sub
 0x00cf9567: drop
 0x00cf9568: local.get $1
 0x00cf956a: v128.load align:4    [SIMD]
 0x00cf956e: local.set $5
 0x00cf9570: local.get $5
 0x00cf9572: v128.not    [SIMD]
 0x00cf9574: local.set $6
 0x00cf9576: local.get $6
 0x00cf9578: drop
 0x00cf9579: local.get $0
 0x00cf957b: local.get $6
 0x00cf957d: v128.store    [SIMD]
 0x00cf9581: return

wasm - Release configuration:

(func idx:7866(param $0 i32, $1 i32, $2 i32))
 0x00185b37: local.get $0
 0x00185b39: local.get $1
 0x00185b3b: v128.load align:4    [SIMD]
 0x00185b3f: v128.not    [SIMD]
 0x00185b41: v128.store    [SIMD]

Add wasm specific implementation of Vector128.OnesComplement method.

Example compilation output. Managed:

    static Vector128<double> SimdTest3(Vector128<double> input)
    {
        return Vector128.OnesComplement(input);
    }

IR:

    BB3:                                              ; preds = %BB2
      %cast_to_4_x_i32 = bitcast <2 x double> %simd_vtype to <4 x i32>
      %wasm_not = xor <4 x i32> %cast_to_4_x_i32, <i32 -1, i32 -1, i32 -1, i32 -1>
      %cast_back = bitcast <4 x i32> %wasm_not to <2 x double>
      br label %BB4

wasm:

    (func Wasm_Console_V8_CJS_Sample_Test_SimdTest3_System_Runtime_Intrinsics_Vector128_1_double(param $0 i32, $1 i32, $2 i32))
     local $3 i32
     local $4 i32
     local $5 v128
     local $6 v128
     0x00cf955a: global.get $__stack_pointer
     0x00cf955c: local.set $3
     0x00cf955e: i32.const 16
     0x00cf9560: local.set $4
     0x00cf9562: local.get $3
     0x00cf9564: local.get $4
     0x00cf9566: i32.sub
     0x00cf9567: drop
     0x00cf9568: local.get $1
     0x00cf956a: v128.load align:4    [SIMD]
     0x00cf956e: local.set $5
     0x00cf9570: local.get $5
     0x00cf9572: v128.not    [SIMD]
     0x00cf9574: local.set $6
     0x00cf9576: local.get $6
     0x00cf9578: drop
     0x00cf9579: local.get $0
     0x00cf957b: local.get $6
     0x00cf957d: v128.store    [SIMD]
     0x00cf9581: return
@radekdoulik
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radekdoulik radekdoulik requested a review from marek-safar as a code owner June 28, 2022 14:03
@radekdoulik
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radekdoulik
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical radical added the arch-wasm WebAssembly architecture label Jun 28, 2022
@ghost
Copy link

ghost commented Jun 28, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Add wasm specific implementation of Vector128.OnesComplement method.

Example compilation output. Managed:

static Vector128<double> SimdTest3(Vector128<double> input)
{
    return Vector128.OnesComplement(input);
}

IR:

BB3:                                              ; preds = %BB2
  %cast_to_4_x_i32 = bitcast <2 x double> %simd_vtype to <4 x i32>
  %wasm_not = xor <4 x i32> %cast_to_4_x_i32, <i32 -1, i32 -1, i32 -1, i32 -1>
  %cast_back = bitcast <4 x i32> %wasm_not to <2 x double>
  br label %BB4

wasm - Debug configuration:

(func Wasm_Console_V8_CJS_Sample_Test_SimdTest3_System_Runtime_Intrinsics_Vector128_1_double(param $0 i32, $1 i32, $2 i32))
 local $3 i32
 local $4 i32
 local $5 v128
 local $6 v128
 0x00cf955a: global.get $__stack_pointer
 0x00cf955c: local.set $3
 0x00cf955e: i32.const 16
 0x00cf9560: local.set $4
 0x00cf9562: local.get $3
 0x00cf9564: local.get $4
 0x00cf9566: i32.sub
 0x00cf9567: drop
 0x00cf9568: local.get $1
 0x00cf956a: v128.load align:4    [SIMD]
 0x00cf956e: local.set $5
 0x00cf9570: local.get $5
 0x00cf9572: v128.not    [SIMD]
 0x00cf9574: local.set $6
 0x00cf9576: local.get $6
 0x00cf9578: drop
 0x00cf9579: local.get $0
 0x00cf957b: local.get $6
 0x00cf957d: v128.store    [SIMD]
 0x00cf9581: return

wasm - Release configuration:

(func idx:7866(param $0 i32, $1 i32, $2 i32))
 0x00185b37: local.get $0
 0x00185b39: local.get $1
 0x00185b3b: v128.load align:4    [SIMD]
 0x00185b3f: v128.not    [SIMD]
 0x00185b41: v128.store    [SIMD]
Author: radekdoulik
Assignees: radekdoulik
Labels:

arch-wasm, area-Codegen-LLVM-mono

Milestone: -

@radekdoulik
Copy link
Member Author

The failing WBTs are known issue, being worked on in #70704

@radekdoulik radekdoulik merged commit 3fb9511 into dotnet:main Jun 28, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Codegen-LLVM-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants