-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[NVPTX] Lower LLVM masked vector loads and stores to PTX #159387
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
dakersnar
wants to merge
5
commits into
llvm:main
Choose a base branch
from
dakersnar:github/dkersnar/masked-store-lowering
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.
+1,180
−77
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
196ca9b
[NVPTX] Lower LLVM masked vector stores to PTX using the new sink sym…
dakersnar 861d812
Clang format
dakersnar 34b9cd8
Update TTI to add enum value representing MaskKind to isLegalMaskedLo…
dakersnar bb1577e
Add masked load lowering support
dakersnar 8b0b5ec
Fix typo
dakersnar 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
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
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,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -march=nvptx64 -mcpu=sm_100 -mattr=+ptx88 | FileCheck %s -check-prefixes=CHECK | ||
; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_100 -mattr=+ptx88 | %ptxas-verify -arch=sm_100 %} | ||
|
||
; Confirm that a masked store with a variable mask is scalarized before lowering | ||
|
||
define void @global_variable_mask(ptr addrspace(1) %a, ptr addrspace(1) %b, <4 x i1> %mask) { | ||
; CHECK-LABEL: global_variable_mask( | ||
; CHECK: { | ||
; CHECK-NEXT: .reg .pred %p<9>; | ||
; CHECK-NEXT: .reg .b16 %rs<9>; | ||
; CHECK-NEXT: .reg .b64 %rd<7>; | ||
; CHECK-EMPTY: | ||
; CHECK-NEXT: // %bb.0: | ||
; CHECK-NEXT: ld.param.b8 %rs1, [global_variable_mask_param_2+3]; | ||
; CHECK-NEXT: ld.param.b8 %rs3, [global_variable_mask_param_2+2]; | ||
; CHECK-NEXT: and.b16 %rs4, %rs3, 1; | ||
; CHECK-NEXT: ld.param.b8 %rs5, [global_variable_mask_param_2+1]; | ||
; CHECK-NEXT: and.b16 %rs6, %rs5, 1; | ||
; CHECK-NEXT: setp.ne.b16 %p2, %rs6, 0; | ||
; CHECK-NEXT: ld.param.b8 %rs7, [global_variable_mask_param_2]; | ||
; CHECK-NEXT: and.b16 %rs8, %rs7, 1; | ||
; CHECK-NEXT: setp.ne.b16 %p1, %rs8, 0; | ||
; CHECK-NEXT: ld.param.b64 %rd5, [global_variable_mask_param_1]; | ||
; CHECK-NEXT: ld.param.b64 %rd6, [global_variable_mask_param_0]; | ||
; CHECK-NEXT: ld.global.v4.b64 {%rd1, %rd2, %rd3, %rd4}, [%rd6]; | ||
; CHECK-NEXT: not.pred %p5, %p1; | ||
; CHECK-NEXT: @%p5 bra $L__BB0_2; | ||
; CHECK-NEXT: // %bb.1: // %cond.store | ||
; CHECK-NEXT: st.global.b64 [%rd5], %rd1; | ||
; CHECK-NEXT: $L__BB0_2: // %else | ||
; CHECK-NEXT: and.b16 %rs2, %rs1, 1; | ||
; CHECK-NEXT: setp.ne.b16 %p3, %rs4, 0; | ||
; CHECK-NEXT: not.pred %p6, %p2; | ||
; CHECK-NEXT: @%p6 bra $L__BB0_4; | ||
; CHECK-NEXT: // %bb.3: // %cond.store1 | ||
; CHECK-NEXT: st.global.b64 [%rd5+8], %rd2; | ||
; CHECK-NEXT: $L__BB0_4: // %else2 | ||
; CHECK-NEXT: setp.ne.b16 %p4, %rs2, 0; | ||
; CHECK-NEXT: not.pred %p7, %p3; | ||
; CHECK-NEXT: @%p7 bra $L__BB0_6; | ||
; CHECK-NEXT: // %bb.5: // %cond.store3 | ||
; CHECK-NEXT: st.global.b64 [%rd5+16], %rd3; | ||
; CHECK-NEXT: $L__BB0_6: // %else4 | ||
; CHECK-NEXT: not.pred %p8, %p4; | ||
; CHECK-NEXT: @%p8 bra $L__BB0_8; | ||
; CHECK-NEXT: // %bb.7: // %cond.store5 | ||
; CHECK-NEXT: st.global.b64 [%rd5+24], %rd4; | ||
; CHECK-NEXT: $L__BB0_8: // %else6 | ||
; CHECK-NEXT: ret; | ||
%a.load = load <4 x i64>, ptr addrspace(1) %a | ||
tail call void @llvm.masked.store.v4i64.p1(<4 x i64> %a.load, ptr addrspace(1) %b, i32 32, <4 x i1> %mask) | ||
ret void | ||
} | ||
|
||
declare void @llvm.masked.store.v4i64.p1(<4 x i64>, ptr addrspace(1), i32, <4 x i1>) |
Oops, something went wrong.
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.
In general, if the purpose of the check is to check validity of X, we should pass X itself. Passing derived into instead of the actual object we're checking makes everyone do potentially unnecessary checks and limits what property of X we get to check. While a bool indicating contness of the masked store is sufficient for us here and now, it's not the best choice for a generic API that potentially needs to work for different architectures with different requirements.
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'd expect this to have a classification similar to the ShuffleKind queries
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.
@arsenm are you imagining an enum rather than a bool? Something like:
enum MaskType {
VariableOrConstantMask,
ConstantMask,
}
This is effectively the same as the bool approach but possibly a bit clearer. Like the bool approach, this would allow:
If this isn't what you had in mind, can you elaborate?
(edit: we could also add VariableMask as a third enum option if for some reason a target had special rules for that specific 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.
Yes, something like that
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.
Done.