-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix vector's Narrow intrinsics #81843
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
Conversation
The BCL Vector classes have non-saturating Narrow methods, while wasm
instructions are saturating. AFAIK wasm doesn;t have non-saturating
narrow instructions. So instead of using
i8x16.narrow_i16x8_s
i8x16.narrow_i16x8_u
i16x8.narrow_i32x4_s
i16x8.narrow_i32x4_u
instructions, use `v8x16.shuffle` instruction to implement the extract
narrow operation.
This fixes `System.Numerics.Tests.GenericVectorTests.Narrow[U]Int*`
tests.
|
Example of emitted code: |
|
Worth noting that saturating narrow is coming: #75724 So might be worth keeping the logic easily accessible so we can turn it back on when the new APIs are added. |
|
@radekdoulik what is the easiest option to check codegen/LLVM IR for a SIMD operation in WASM? I assume I need to use one of the WASM samples but how/where do I specify |
I usually use For checking generated wasm code I use |
which sample would you recommend to use for that? |
|
The easiest is probably src/mono/samples/wasm/console-v8. |
|
If you want to run the cross compiler by hand, build the sample using: |
|
The failing build is #81859 |
The BCL Vector classes have non-saturating Narrow methods, while wasm instructions are saturating. AFAIK wasm does not have non-saturating narrow instructions. So instead of
use
v8x16.shuffleinstruction to implement the extract narrow operation.This fixes
System.Numerics.Tests.GenericVectorTests.Narrow[U]Int*tests.