-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[WebAssembly] Add pattern for relaxed laneselect (from bitselect simd) #163807
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
Open
badumbatish
wants to merge
3
commits into
llvm:main
Choose a base branch
from
badumbatish:select
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+90
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
|
|
||
| ; RUN: llc < %s -verify-machineinstrs -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128,+relaxed-simd | FileCheck %s --check-prefix=RELAXED | ||
| ; RUN: llc < %s -verify-machineinstrs -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s --check-prefix=SIMD | ||
|
|
||
| ; Test that bitselect intrinsic lowers to relaxed_laneselect when relaxed-simd is enabled | ||
|
|
||
| target triple = "wasm32-unknown-unknown" | ||
|
|
||
| define <16 x i8> @bitselect_to_laneselect_v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) { | ||
| ; RELAXED-LABEL: bitselect_to_laneselect_v16i8: | ||
| ; RELAXED: .functype bitselect_to_laneselect_v16i8 (v128, v128, v128) -> (v128) | ||
| ; RELAXED-NEXT: # %bb.0: | ||
| ; RELAXED-NEXT: i8x16.relaxed_laneselect $push0=, $0, $1, $2 | ||
| ; RELAXED-NEXT: # fallthrough-return | ||
| ; | ||
| ; SIMD-LABEL: bitselect_to_laneselect_v16i8: | ||
| ; SIMD: .functype bitselect_to_laneselect_v16i8 (v128, v128, v128) -> (v128) | ||
| ; SIMD-NEXT: # %bb.0: | ||
| ; SIMD-NEXT: v128.bitselect $push0=, $0, $1, $2 | ||
| ; SIMD-NEXT: # fallthrough-return | ||
| %res = call <16 x i8> @llvm.wasm.bitselect.v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) | ||
| ret <16 x i8> %res | ||
| } | ||
|
|
||
| define <8 x i16> @bitselect_to_laneselect_v8i16(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c) { | ||
| ; RELAXED-LABEL: bitselect_to_laneselect_v8i16: | ||
| ; RELAXED: .functype bitselect_to_laneselect_v8i16 (v128, v128, v128) -> (v128) | ||
| ; RELAXED-NEXT: # %bb.0: | ||
| ; RELAXED-NEXT: i16x8.relaxed_laneselect $push0=, $0, $1, $2 | ||
| ; RELAXED-NEXT: # fallthrough-return | ||
| ; | ||
| ; SIMD-LABEL: bitselect_to_laneselect_v8i16: | ||
| ; SIMD: .functype bitselect_to_laneselect_v8i16 (v128, v128, v128) -> (v128) | ||
| ; SIMD-NEXT: # %bb.0: | ||
| ; SIMD-NEXT: v128.bitselect $push0=, $0, $1, $2 | ||
| ; SIMD-NEXT: # fallthrough-return | ||
| %res = call <8 x i16> @llvm.wasm.bitselect.v8i16(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c) | ||
| ret <8 x i16> %res | ||
| } | ||
|
|
||
| define <4 x i32> @bitselect_to_laneselect_v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { | ||
| ; RELAXED-LABEL: bitselect_to_laneselect_v4i32: | ||
| ; RELAXED: .functype bitselect_to_laneselect_v4i32 (v128, v128, v128) -> (v128) | ||
| ; RELAXED-NEXT: # %bb.0: | ||
| ; RELAXED-NEXT: i32x4.relaxed_laneselect $push0=, $0, $1, $2 | ||
| ; RELAXED-NEXT: # fallthrough-return | ||
| ; | ||
| ; SIMD-LABEL: bitselect_to_laneselect_v4i32: | ||
| ; SIMD: .functype bitselect_to_laneselect_v4i32 (v128, v128, v128) -> (v128) | ||
| ; SIMD-NEXT: # %bb.0: | ||
| ; SIMD-NEXT: v128.bitselect $push0=, $0, $1, $2 | ||
| ; SIMD-NEXT: # fallthrough-return | ||
| %res = call <4 x i32> @llvm.wasm.bitselect.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <2 x i64> @bitselect_to_laneselect_v2i64(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) { | ||
| ; RELAXED-LABEL: bitselect_to_laneselect_v2i64: | ||
| ; RELAXED: .functype bitselect_to_laneselect_v2i64 (v128, v128, v128) -> (v128) | ||
| ; RELAXED-NEXT: # %bb.0: | ||
| ; RELAXED-NEXT: i64x2.relaxed_laneselect $push0=, $0, $1, $2 | ||
| ; RELAXED-NEXT: # fallthrough-return | ||
| ; | ||
| ; SIMD-LABEL: bitselect_to_laneselect_v2i64: | ||
| ; SIMD: .functype bitselect_to_laneselect_v2i64 (v128, v128, v128) -> (v128) | ||
| ; SIMD-NEXT: # %bb.0: | ||
| ; SIMD-NEXT: v128.bitselect $push0=, $0, $1, $2 | ||
| ; SIMD-NEXT: # fallthrough-return | ||
| %res = call <2 x i64> @llvm.wasm.bitselect.v2i64(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) | ||
| ret <2 x i64> %res | ||
| } | ||
|
|
||
|
|
||
|
|
||
| declare <16 x i8> @llvm.wasm.bitselect.v16i8(<16 x i8>, <16 x i8>, <16 x i8>) | ||
| declare <8 x i16> @llvm.wasm.bitselect.v8i16(<8 x i16>, <8 x i16>, <8 x i16>) | ||
| declare <4 x i32> @llvm.wasm.bitselect.v4i32(<4 x i32>, <4 x i32>, <4 x i32>) | ||
| declare <2 x i64> @llvm.wasm.bitselect.v2i64(<2 x i64>, <2 x i64>, <2 x i64>) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there not just be a relaxed form of the intrinsic, just like laneselect above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm can you clarify a bit on that, i think i'm a bit lost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I think Sam means is that there should probably be a separate intrinsic for relaxed laneselect rather than selecting the bitselect intrinsic to laneselect. (At least, that's what my feedback would be :)
The reason is that our current convention is that the @llvm.wasm.foo intrinsics each correspond directly to a particular wasm instruction, so if a user generates bitselect intrinsic, they probably want its particular semantics. Or put another way, the semantics of the existing @llvm.wasm.bitselect intrinsic currently correspond to the bitselect instruction which has more strict semantics than the relaxed laneselect instruction; so implementing the intrinsic with the laneselect instruction would be incorrect.
The conventions of the intrinsics in the @llvm.wasm space are something that could in principle be changed, but I don't think we'd want to do that in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm i think there is already an intrinsics
int_wasm_relaxed_laneselectfor it at llvm/include/llvm/IR/IntrinsicsWebAssembly.td, but in this PR, i was hoping to convert the bitselect to the laneselect when the relaxed flag is present. Should I be doing something else here?