-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Check VL dominates and potentially move in tryReduceVL #106753
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
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,19 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s | ||
|
||
define void @avl_not_dominated(<vscale x 2 x i32> %v, ptr %p) { | ||
; CHECK-LABEL: avl_not_dominated: | ||
; CHECK: # %bb.0: | ||
; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma | ||
; CHECK-NEXT: vmv.x.s a1, v8 | ||
; CHECK-NEXT: slli a1, a1, 32 | ||
; CHECK-NEXT: srli a1, a1, 32 | ||
; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma | ||
; CHECK-NEXT: vadd.vi v8, v8, 1 | ||
; CHECK-NEXT: vse32.v v8, (a0) | ||
; CHECK-NEXT: ret | ||
%w = add <vscale x 2 x i32> %v, splat (i32 1) | ||
%evl = extractelement <vscale x 2 x i32> %v, i32 0 | ||
call void @llvm.vp.store(<vscale x 2 x i32> %w, ptr %p, <vscale x 2 x i1> splat(i1 true), i32 %evl) | ||
ret void | ||
} |
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,15 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc %s -o - -mtriple=riscv64 -mattr=+v -run-pass=riscv-vector-peephole \ | ||
# RUN: -verify-machineinstrs | FileCheck %s | ||
--- | ||
name: avl_not_dominated | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: avl_not_dominated | ||
; CHECK: %evl:gprnox0 = ADDI $x0, 1 | ||
; CHECK-NEXT: %x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, %evl, 5 /* e32 */, 0 /* tu, mu */ | ||
; CHECK-NEXT: PseudoVSE32_V_M1 %x, $noreg, %evl, 5 /* e32 */ | ||
%x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 5 /* e32 */, 0 /* tu, mu */ | ||
%evl:gprnox0 = ADDI $x0, 1 | ||
PseudoVSE32_V_M1 %x:vr, $noreg, %evl, 5 /* e32 */ | ||
... |
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.
Noticing the FIXME. I assume this is something you noticed when inspecting the code? How can a VL (scalar) be a VO (vector) register def? And if it's safe to move, doesn't that guarantee the reaching VO is the same?
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.
V0Defs stores the current definition of V0 at each instruction, so this is about updating the current value at Src if we move it.
isSafeToMove checks that any physical register uses aren't clobbered, so if Src doesn't use V0 then it might be moved past a new V0 def.
So masked pseudos won't get moved currently and I don't think we miscompile anything, but we should probably do our bookkeeping here 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.
Other option is to only add instructions which have a mask use to the mapping, then moving source wouldn't need to update the mapping. Would also keep the mapping (much) smaller.