-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[RISCV] Combine vslide{up,down} x, poison -> x #169013
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
Merged
Merged
Changes from all commits
Commits
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
91 changes: 91 additions & 0 deletions
91
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vector-splice.ll
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,91 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | ||
| ; RUN: llc -mtriple riscv32 -mattr=+v < %s | FileCheck %s | ||
| ; RUN: llc -mtriple riscv64 -mattr=+v < %s | FileCheck %s | ||
| ; RUN: llc -mtriple riscv32 -mattr=+v,+vl-dependent-latency < %s | FileCheck %s | ||
| ; RUN: llc -mtriple riscv64 -mattr=+v,+vl-dependent-latency < %s | FileCheck %s | ||
|
|
||
| define <4 x i32> @splice_v4i32_slidedown(<4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-LABEL: splice_v4i32_slidedown: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vrgather.vi v9, v8, 3 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OT: We should probably be preferring vslidedown.vi for case where we have a single element in the resulting shuffle mask. vrgather.vi forces the use of an extra register where vslidedown.vi doesn't. (This only works for vslidedown, vslideup does have the register constraint.) |
||
| ; CHECK-NEXT: vmv.v.v v8, v9 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <4 x i32> @llvm.vector.splice(<4 x i32> %a, <4 x i32> poison, i32 3) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @splice_4i32_slideup(<4 x i32> %a) { | ||
| ; CHECK-LABEL: splice_4i32_slideup: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vrgather.vi v9, v8, 0 | ||
| ; CHECK-NEXT: vmv.v.v v8, v9 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <4 x i32> @llvm.vector.splice(<4 x i32> poison, <4 x i32> %a, i32 -3) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <8 x i32> @splice_v8i32_slidedown(<8 x i32> %a, <8 x i32> %b) { | ||
| ; CHECK-LABEL: splice_v8i32_slidedown: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
| ; CHECK-NEXT: vslidedown.vi v8, v8, 3 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <8 x i32> @llvm.vector.splice(<8 x i32> %a, <8 x i32> poison, i32 3) | ||
| ret <8 x i32> %res | ||
| } | ||
|
|
||
| define <8 x i32> @splice_v8i32_slideup(<8 x i32> %a) { | ||
| ; CHECK-LABEL: splice_v8i32_slideup: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
| ; CHECK-NEXT: vslideup.vi v10, v8, 3 | ||
| ; CHECK-NEXT: vmv.v.v v8, v10 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <8 x i32> @llvm.vector.splice(<8 x i32> poison, <8 x i32> %a, i32 -3) | ||
| ret <8 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @splice_v4i32_slidedown_undef(<4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-LABEL: splice_v4i32_slidedown_undef: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vrgather.vi v9, v8, 3 | ||
| ; CHECK-NEXT: vmv.v.v v8, v9 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <4 x i32> @llvm.vector.splice(<4 x i32> %a, <4 x i32> undef, i32 3) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @splice_4i32_slideup_undef(<4 x i32> %a) { | ||
| ; CHECK-LABEL: splice_4i32_slideup_undef: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vrgather.vi v9, v8, 0 | ||
| ; CHECK-NEXT: vmv.v.v v8, v9 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <4 x i32> @llvm.vector.splice(<4 x i32> undef, <4 x i32> %a, i32 -3) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <8 x i32> @splice_v8i32_slidedown_undef(<8 x i32> %a, <8 x i32> %b) { | ||
| ; CHECK-LABEL: splice_v8i32_slidedown_undef: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
| ; CHECK-NEXT: vslidedown.vi v8, v8, 3 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <8 x i32> @llvm.vector.splice(<8 x i32> %a, <8 x i32> undef, i32 3) | ||
| ret <8 x i32> %res | ||
| } | ||
|
|
||
| define <8 x i32> @splice_v8i32_slideup_undef(<8 x i32> %a) { | ||
| ; CHECK-LABEL: splice_v8i32_slideup_undef: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma | ||
| ; CHECK-NEXT: vslideup.vi v10, v8, 3 | ||
| ; CHECK-NEXT: vmv.v.v v8, v10 | ||
| ; CHECK-NEXT: ret | ||
| %res = call <8 x i32> @llvm.vector.splice(<8 x i32> undef, <8 x i32> %a, i32 -3) | ||
| ret <8 x i32> %res | ||
| } | ||
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
Oops, something went wrong.
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.
Does this work with isPoison? isUndef returns true for poison and for undef, but we only tested poison.
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.
independent from what we test: I think this transformation still holds for undef, right?
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.
I think it's valid for undef.
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.
If we add an undef test then the undef detector linter will complain.
For the use case in the loop vectorizer just handling poison is fine if we want to avoid isUndef. Are we moving away from it in SelectionDAG?
Uh oh!
There was an error while loading. Please reload this page.
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.
SelectionDAG support for poison is still in an early stage I think. It probably converts ISD::POISON to ISD::UNDEF in many cases still. I wouldn't be surprised if the vector was ISD::UNDEF by the time it gets here. Especially for the fixed vector 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.
Ok, just want to check then should we add a test case with undef anyway?
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.
Yes, please ignore the linter.