-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Add out-of-bounds fallback for AdvSimd.ShiftRightLogical #105777
Conversation
cc @dotnet/jit-contrib, @tannergooding PTAL. |
src/coreclr/jit/hwintrinsicarm64.cpp
Outdated
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)); |
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.
Is the spilling necessary?
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 assumed we would need it since we do the same for AVX2/SSE intrinsics, but looks like we don't need it. Fixed.
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.
yep, we don't. Here op1 is still evaluated before op2 so all good
@@ -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. | |||
|
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.
We usually copy-paste Fuzzlyn's header for repros
Fixes #105621. When its immediate is out-of-bounds,
AdvSimd.ShiftRightLogical
can be transformed intoAdvSimd.ShiftLogical
, which takes the immediate in a register. This meansAdvSimd.ShiftRightLogical
will no longer throwArgumentOutOfRangeException
in Debug or Release; when optimizing, we'd previously fold the intrinsic away, thus creating behavioral discrepancies.