JIT: Add out-of-bounds fallback for AdvSimd.ShiftRightLogical#105777
Merged
amanasifkhalid merged 2 commits intodotnet:mainfrom Aug 1, 2024
Merged
JIT: Add out-of-bounds fallback for AdvSimd.ShiftRightLogical#105777amanasifkhalid merged 2 commits intodotnet:mainfrom
amanasifkhalid merged 2 commits intodotnet:mainfrom
Conversation
Contributor
Author
|
cc @dotnet/jit-contrib, @tannergooding PTAL. |
tannergooding
approved these changes
Jul 31, 2024
jakobbotsch
reviewed
Jul 31, 2024
src/coreclr/jit/hwintrinsicarm64.cpp
Outdated
Comment on lines
573
to
584
| impSpillSideEffect(true, | ||
| verCurrentState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic")); | ||
|
|
||
| GenTree* op2 = impPopStack().val; | ||
| GenTree* op1 = impSIMDPopStack(); | ||
|
|
||
| // AdvSimd.ShiftLogical does right-shifts with negative immediates, hence the negation | ||
| GenTree* tmpOp = | ||
| gtNewSimdCreateBroadcastNode(simdType, gtNewOperNode(GT_NEG, genActualType(op2->TypeGet()), op2), | ||
| simdBaseJitType, genTypeSize(simdType)); | ||
| return gtNewSimdHWIntrinsicNode(simdType, op1, tmpOp, NI_AdvSimd_ShiftLogical, simdBaseJitType, | ||
| genTypeSize(simdType)); |
Contributor
Author
There was a problem hiding this comment.
I assumed we would need it since we do the same for AVX2/SSE intrinsics, but looks like we don't need it. Fixed.
Member
There was a problem hiding this comment.
yep, we don't. Here op1 is still evaluated before op2 so all good
EgorBo
reviewed
Jul 31, 2024
| @@ -0,0 +1,32 @@ | |||
| // Licensed to the .NET Foundation under one or more agreements. | |||
| // The .NET Foundation licenses this file to you under the MIT license. | |||
|
|
|||
Member
There was a problem hiding this comment.
We usually copy-paste Fuzzlyn's header for repros
EgorBo
approved these changes
Aug 1, 2024
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #105621. When its immediate is out-of-bounds,
AdvSimd.ShiftRightLogicalcan be transformed intoAdvSimd.ShiftLogical, which takes the immediate in a register. This meansAdvSimd.ShiftRightLogicalwill no longer throwArgumentOutOfRangeExceptionin Debug or Release; when optimizing, we'd previously fold the intrinsic away, thus creating behavioral discrepancies.