-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Implement Vector.AddSaturate/SubtractSaturate #107193
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3a12fe6
Implement Vector.AddSaturate / SubtractSaturate
lilinus ad5f344
Add tests
lilinus 9ee124c
Cleanup VectorMath
lilinus 0e69a94
Optimize add/sub saturate fallback
lilinus 6cf7033
Implement intrinsics in runtime
lilinus 3defc25
Merge branch 'main' into add-sub-saturate
lilinus e7a637b
Fixes to Vector.Add/SubSaturate
lilinus 435a7be
Apply format patch
lilinus d357672
Merge branch 'main' into add-sub-saturate
lilinus ec2b8c4
Merge branch 'main' into add-sub-saturate
lilinus 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 |
|---|---|---|
|
|
@@ -709,6 +709,30 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, | |
| break; | ||
| } | ||
|
|
||
| case NI_Vector64_AddSaturate: | ||
| case NI_Vector128_AddSaturate: | ||
| { | ||
| assert(sig->numArgs == 2); | ||
|
|
||
| if (simdSize == 8 && varTypeIsLong(simdBaseType)) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| op2 = impSIMDPopStack(); | ||
| op1 = impSIMDPopStack(); | ||
| if (varTypeIsFloating(simdBaseType)) | ||
| { | ||
| retNode = gtNewSimdBinOpNode(GT_ADD, retType, op1, op2, simdBaseJitType, simdSize); | ||
| } | ||
| else | ||
| { | ||
| retNode = | ||
| gtNewSimdHWIntrinsicNode(retType, op1, op2, NI_AdvSimd_AddSaturate, simdBaseJitType, simdSize); | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case NI_AdvSimd_BitwiseClear: | ||
| case NI_Vector64_AndNot: | ||
| case NI_Vector128_AndNot: | ||
|
|
@@ -2097,6 +2121,30 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, | |
| break; | ||
| } | ||
|
|
||
| case NI_Vector64_SubtractSaturate: | ||
| case NI_Vector128_SubtractSaturate: | ||
| { | ||
| assert(sig->numArgs == 2); | ||
|
|
||
| if (simdSize == 8 && varTypeIsLong(simdBaseType)) | ||
| { | ||
| break; | ||
| } | ||
|
Comment on lines
+2129
to
+2132
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. Same here, this should just use |
||
|
|
||
| op2 = impSIMDPopStack(); | ||
| op1 = impSIMDPopStack(); | ||
| if (varTypeIsFloating(simdBaseType)) | ||
| { | ||
| retNode = gtNewSimdBinOpNode(GT_SUB, retType, op1, op2, simdBaseJitType, simdSize); | ||
| } | ||
| else | ||
| { | ||
| retNode = | ||
| gtNewSimdHWIntrinsicNode(retType, op1, op2, NI_AdvSimd_SubtractSaturate, simdBaseJitType, simdSize); | ||
| } | ||
| break; | ||
| } | ||
|
|
||
| case NI_Vector64_op_LeftShift: | ||
| case NI_Vector128_op_LeftShift: | ||
| { | ||
|
|
||
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.
This shouldn't be skipped for
TYP_LONG, it should just useAddSaturateScalarwhich is already exposed.