-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[RISCV][VLOPT] Added support for vmv.s.x and vfmv.s.f #149562
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
mikhailramalho
wants to merge
6
commits into
llvm:main
Choose a base branch
from
mikhailramalho:vlopt-vfmv-1
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b54de9
Added support for vmv and vfmv
mikhailramalho a703c3b
Check for loops
mikhailramalho 54b5107
Slightly improve on the code
mikhailramalho 01b806b
Revert "Slightly improve on the code"
mikhailramalho f6add81
Revert "Check for loops"
mikhailramalho f3c0432
Move enum values
mikhailramalho 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
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
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 |
---|---|---|
|
@@ -129,9 +129,8 @@ define <vscale x 8 x i8> @insertelt_nxv8i8_idx(<vscale x 8 x i8> %v, i8 signext | |
; CHECK-LABEL: insertelt_nxv8i8_idx: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: addi a2, a1, 1 | ||
; CHECK-NEXT: vsetvli a3, zero, e8, m1, ta, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
; CHECK-NEXT: vsetvli zero, a2, e8, m1, tu, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
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. That's interesting that we now perform the vmv.s.x in tu policy. I thought that we didn't go from ta -> tu generally? Is the passthru in this vmv.s.x not poison? Either way I'm going out on a limb here and assuming this is profitable given we're avoiding a VL toggle |
||
; CHECK-NEXT: vslideup.vx v8, v9, a1 | ||
; CHECK-NEXT: ret | ||
%r = insertelement <vscale x 8 x i8> %v, i8 %elt, i32 %idx | ||
|
@@ -333,9 +332,8 @@ define <vscale x 4 x i16> @insertelt_nxv4i16_idx(<vscale x 4 x i16> %v, i16 sign | |
; CHECK-LABEL: insertelt_nxv4i16_idx: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: addi a2, a1, 1 | ||
; CHECK-NEXT: vsetvli a3, zero, e16, m1, ta, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
; CHECK-NEXT: vsetvli zero, a2, e16, m1, tu, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
; CHECK-NEXT: vslideup.vx v8, v9, a1 | ||
; CHECK-NEXT: ret | ||
%r = insertelement <vscale x 4 x i16> %v, i16 %elt, i32 %idx | ||
|
@@ -503,9 +501,8 @@ define <vscale x 2 x i32> @insertelt_nxv2i32_idx(<vscale x 2 x i32> %v, i32 sign | |
; CHECK-LABEL: insertelt_nxv2i32_idx: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: addi a2, a1, 1 | ||
; CHECK-NEXT: vsetvli a3, zero, e32, m1, ta, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
; CHECK-NEXT: vsetvli zero, a2, e32, m1, tu, ma | ||
; CHECK-NEXT: vmv.s.x v9, a0 | ||
; CHECK-NEXT: vslideup.vx v8, v9, a1 | ||
; CHECK-NEXT: ret | ||
%r = insertelement <vscale x 2 x i32> %v, i32 %elt, i32 %idx | ||
|
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.
An extra vsetvli is being created here
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.
Looking at the code for this example, this looks to be an inloop reduction which should be super rare in practice. For vadd, we really should be doing an out of loop reduction instead.
One thing that's worth investigating (but not blocking this review) is why for this case the extra vsetvli isn't being PREd into the loop header. If it was, even in this case the extra toggle would be loop invariant (and I think our backwards walk would kill the toggle anyways.).
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.
IIUC, doPRE doesn't handle the loop we see in this program, so it bails.
I'm writing a patch to change that, and removing the WIP from this PR, as changing doPRE is out of the scope of this PR.