-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Expose the FusedMultiplyAdd and MultiplyAddEstimate APIs on relevant vector and scalar types #102181
Expose the FusedMultiplyAdd and MultiplyAddEstimate APIs on relevant vector and scalar types #102181
Changes from all commits
46caa78
940862e
d5b2ad9
731258f
4010235
8a60cff
5e1e5eb
85425c2
0896be6
fdd2a83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1347,6 +1347,26 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, | |
break; | ||
} | ||
|
||
case NI_Vector64_FusedMultiplyAdd: | ||
case NI_Vector128_FusedMultiplyAdd: | ||
{ | ||
assert(sig->numArgs == 3); | ||
assert(varTypeIsFloating(simdBaseType)); | ||
|
||
impSpillSideEffect(true, verCurrentState.esStackDepth - | ||
3 DEBUGARG("Spilling op1 side effects for FusedMultiplyAdd")); | ||
|
||
impSpillSideEffect(true, verCurrentState.esStackDepth - | ||
2 DEBUGARG("Spilling op2 side effects for FusedMultiplyAdd")); | ||
|
||
op3 = impSIMDPopStack(); | ||
op2 = impSIMDPopStack(); | ||
op1 = impSIMDPopStack(); | ||
|
||
retNode = gtNewSimdFmaNode(retType, op1, op2, op3, simdBaseJitType, simdSize); | ||
break; | ||
} | ||
|
||
case NI_Vector64_get_AllBitsSet: | ||
case NI_Vector128_get_AllBitsSet: | ||
{ | ||
|
@@ -1691,6 +1711,31 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, | |
break; | ||
} | ||
|
||
case NI_Vector64_MultiplyAddEstimate: | ||
case NI_Vector128_MultiplyAddEstimate: | ||
{ | ||
assert(sig->numArgs == 3); | ||
assert(varTypeIsFloating(simdBaseType)); | ||
|
||
if (BlockNonDeterministicIntrinsics(mustExpand)) | ||
{ | ||
break; | ||
} | ||
|
||
impSpillSideEffect(true, verCurrentState.esStackDepth - | ||
3 DEBUGARG("Spilling op1 side effects for MultiplyAddEstimate")); | ||
|
||
impSpillSideEffect(true, verCurrentState.esStackDepth - | ||
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. Isn't better/simpler to use 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. It's not something we've been doing in other scenarios. AFAIR it comes down to not spilling values on the stack that aren't impacted. For example, we take 3 args, but the stack could have 4+ on it (spilling these is unnecessary since they are still processed in order with respect to our own So we're doing this to ensure only the minimum number of items that need to be spilled are spilled. |
||
2 DEBUGARG("Spilling op2 side effects for MultiplyAddEstimate")); | ||
|
||
op3 = impSIMDPopStack(); | ||
op2 = impSIMDPopStack(); | ||
op1 = impSIMDPopStack(); | ||
|
||
retNode = gtNewSimdFmaNode(retType, op1, op2, op3, simdBaseJitType, simdSize); | ||
break; | ||
} | ||
|
||
case NI_Vector64_Narrow: | ||
case NI_Vector128_Narrow: | ||
{ | ||
|
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 am just curious - who's responsible to spill them?
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.
Ah, nvm, I see
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.
Typically it's the importer code, prior to calling this method. Latter phases that might call such an API (like morph) are responsible for ensuring the swap is safe in the face of potential side effects.
There's, unfortunately, not really a way for us to do such a swap safely in the API itself (at least that I know of) nor to know if the caller has actually done it. So the typical approach has been to do the swap and comment that callers should be doing the validation.