-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Optimize VectorX<T>.ConditionalSelect for constant masks #104092
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 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d777025
Optimize ConditionalSelect for const mask
ezhevita 3ba78a3
Cleanup code and separate it into functions
ezhevita edef328
fix build
ezhevita 0d2059a
Misc fixes
ezhevita 1be2a81
Final build fixes
ezhevita f8813bc
Merge branch 'dotnet:main' into optimize-cndsel
ezhevita f9462d0
Address review comments
ezhevita b5a9ebc
Address review comments again
ezhevita 59beb90
address the rest of the comments
ezhevita ac14fe2
Remove scalar assertion
ezhevita 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29442,6 +29442,57 @@ bool GenTree::IsInvariant() const | |
| return OperIsConst() || OperIs(GT_LCL_ADDR) || OperIs(GT_FTN_ADDR); | ||
| } | ||
|
|
||
| //------------------------------------------------------------------- | ||
| // IsVectorPerElementMask: returns true if this node is a vector constant per-element mask | ||
| // (every element has either all bits set or none of them). | ||
| // | ||
| // Returns: | ||
| // True if this node is a vector constant per-element mask | ||
| // | ||
| bool GenTree::IsVectorPerElementMask(var_types simdBaseType, unsigned simdSize) const | ||
ezhevita marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| #ifdef FEATURE_SIMD | ||
| if (IsCnsVec()) | ||
| { | ||
| const GenTreeVecCon* vecCon = AsVecCon(); | ||
| if (vecCon->IsAllBitsSet() || vecCon->IsZero()) | ||
ezhevita marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| return true; | ||
| } | ||
|
|
||
| int elementCount = vecCon->ElementCount(simdSize, simdBaseType); | ||
|
|
||
| switch (simdBaseType) | ||
| { | ||
| case TYP_BYTE: | ||
| case TYP_UBYTE: | ||
| return ElementsAreAllBitsSetOrZero(&vecCon->gtSimdVal.u8[0], elementCount); | ||
| case TYP_SHORT: | ||
| case TYP_USHORT: | ||
| return ElementsAreAllBitsSetOrZero(&vecCon->gtSimdVal.u16[0], elementCount); | ||
| case TYP_INT: | ||
| case TYP_UINT: | ||
| case TYP_FLOAT: | ||
| return ElementsAreAllBitsSetOrZero(&vecCon->gtSimdVal.u32[0], elementCount); | ||
| case TYP_LONG: | ||
| case TYP_ULONG: | ||
| case TYP_DOUBLE: | ||
| return ElementsAreAllBitsSetOrZero(&vecCon->gtSimdVal.u64[0], elementCount); | ||
| default: | ||
| unreached(); | ||
| } | ||
| } | ||
| else if (OperIsHWIntrinsic()) | ||
| { | ||
| // TODO-XARCH-AVX512 Use VPBLENDM* and take input directly from K registers if cond is from | ||
| // MoveMaskToVectorSpecial. | ||
|
||
| return HWIntrinsicInfo::ReturnsPerElementMask(AsHWIntrinsic()->GetHWIntrinsicId()); | ||
tannergooding marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| #endif // FEATURE_SIMD | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------ | ||
| // IsNeverNegative: returns true if the given tree is known to be never | ||
| // negative, i. e. the upper bit will always be zero. | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.