-
Notifications
You must be signed in to change notification settings - Fork 5k
Add pattern matching for SVE intrinsics that operate on mask operands #114438
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
kunalspathak
merged 15 commits into
dotnet:main
from
snickolls-arm:sve-use-all-predicate-variants
May 20, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c5922a1
Add pattern matching for SVE intrinsics that operate on mask operands
snickolls-arm 3ee0230
Fix test failure and add FileCheck tests
snickolls-arm 782d7fd
Don't run tests on OSX
snickolls-arm 8793f72
Don't run tests for Mono
snickolls-arm 0b56784
Move the transform later in fgOptimizeHWIntrinsic
snickolls-arm 0378754
Rename gtNewSimdAllFalseMaskNode
snickolls-arm ff2df6c
Re-design using HW_Flag_AllMaskVariant
snickolls-arm 2cec188
Merge remote-tracking branch 'origin/main' into sve-use-all-predicate…
kunalspathak f067baa
Add missing function documentation in hwintrinsic.h
snickolls-arm eae2622
Fix integer comparison and add assertion
snickolls-arm e28622a
Refactor to follow similar path to XARCH
snickolls-arm 713ab96
fix the refactoring
kunalspathak 0637900
Merge branch 'main' into sve-use-all-predicate-variants
kunalspathak 0b4e5db
jit formatting
kunalspathak c77c83e
Move code into morph.cpp
snickolls-arm 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 |
---|---|---|
|
@@ -233,6 +233,11 @@ enum HWIntrinsicFlag : unsigned int | |
// The intrinsic is a reduce operation. | ||
HW_Flag_ReduceOperation = 0x2000000, | ||
|
||
// This intrinsic could be implemented with another intrinsic when it is operating on operands that are all of | ||
// type TYP_MASK, and this other intrinsic will produces a value of this type. Used in morph to convert vector | ||
// operations into mask operations when the intrinsic is operating on mask vectors (mainly bitwise operations). | ||
HW_Flag_HasAllMaskVariant = 0x4000000, | ||
|
||
#else | ||
#error Unsupported platform | ||
#endif | ||
|
@@ -1133,6 +1138,67 @@ struct HWIntrinsicInfo | |
} | ||
} | ||
|
||
#ifdef FEATURE_MASKED_HW_INTRINSICS | ||
// HasAllMaskVariant: Does the intrinsic have an intrinsic variant that operates on mask types? | ||
// | ||
// Arguments: | ||
// id -- the intrinsic to check for a mask-type variant. | ||
// | ||
// Return Value: | ||
// true when the intrinsic has a mask-type variant, else false | ||
// | ||
static bool HasAllMaskVariant(NamedIntrinsic id) | ||
{ | ||
const HWIntrinsicFlag flags = lookupFlags(id); | ||
return (flags & HW_Flag_HasAllMaskVariant) != 0; | ||
} | ||
|
||
// GetMaskVariant: Given an intrinsic that has a variant that operates on mask types, return the ID of | ||
// this variant intrinsic. Call HasAllMaskVariant before using this function, as it will | ||
// assert if no match is found. | ||
// | ||
// Arguments: | ||
// id -- the intrinsic with a mask-type variant. | ||
// | ||
// Return Value: | ||
// The ID of the mask-type variant for the given intrinsic | ||
// | ||
static NamedIntrinsic GetMaskVariant(NamedIntrinsic id) | ||
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. i know lot of methods in this file don't have method summary, but we try to add them for newly added methods. So please add a line or 2 for them. |
||
{ | ||
assert(HasAllMaskVariant(id)); | ||
switch (id) | ||
{ | ||
case NI_Sve_And: | ||
return NI_Sve_And_Predicates; | ||
case NI_Sve_BitwiseClear: | ||
return NI_Sve_BitwiseClear_Predicates; | ||
case NI_Sve_Xor: | ||
return NI_Sve_Xor_Predicates; | ||
case NI_Sve_Or: | ||
return NI_Sve_Or_Predicates; | ||
case NI_Sve_ZipHigh: | ||
return NI_Sve_ZipHigh_Predicates; | ||
case NI_Sve_ZipLow: | ||
return NI_Sve_ZipLow_Predicates; | ||
case NI_Sve_UnzipOdd: | ||
return NI_Sve_UnzipOdd_Predicates; | ||
case NI_Sve_UnzipEven: | ||
return NI_Sve_UnzipEven_Predicates; | ||
case NI_Sve_TransposeEven: | ||
return NI_Sve_TransposeEven_Predicates; | ||
case NI_Sve_TransposeOdd: | ||
return NI_Sve_TransposeOdd_Predicates; | ||
case NI_Sve_ReverseElement: | ||
return NI_Sve_ReverseElement_Predicates; | ||
case NI_Sve_ConditionalSelect: | ||
return NI_Sve_ConditionalSelect_Predicates; | ||
|
||
default: | ||
unreached(); | ||
} | ||
} | ||
#endif // FEATURE_MASKED_HW_INTRINSICS | ||
|
||
#endif // TARGET_ARM64 | ||
|
||
static bool HasSpecialSideEffect(NamedIntrinsic id) | ||
|
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
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.
may be in a follow-up PR, add
assert(HasAllMaskVariant(id));
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.
actually, there is a build failure, so can you fix this as well along with fixing the build error?