- Notifications
You must be signed in to change notification settings - Fork5.2k
Accelerate Vector128<long>::op_Multiply on x64#103555
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from19 commits
ae17211afda312ab0157421b42de581f1e249a359f57898f0f1be70595d0eb8dcfd93d7fec9e3e1722960456d128af610469572a2d607549573a37b3790d1b60441f35b78dddcc257ddFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21592,11 +21592,55 @@ GenTree* Compiler::gtNewSimdBinOpNode( | ||
| { | ||
| intrinsic = NI_AVX10v1_MultiplyLow; | ||
| } | ||
| else if (compOpportunisticallyDependsOn(InstructionSet_AVX512DQ_VL)) | ||
tannergooding marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| { | ||
| intrinsic = NI_AVX512DQ_VL_MultiplyLow; | ||
| } | ||
| else | ||
| { | ||
| assert(((simdSize == 16) && compOpportunisticallyDependsOn(InstructionSet_SSE41)) || | ||
| ((simdSize == 32) && compOpportunisticallyDependsOn(InstructionSet_AVX2))); | ||
| // Make op1 and op2 multi-use: | ||
| GenTree* op1Dup = fgMakeMultiUse(&op1); | ||
| GenTree* op2Dup = fgMakeMultiUse(&op2); | ||
| const bool is256 = simdSize == 32; | ||
| // Vector256<ulong> tmp0 = Avx2.Multiply(left, right); | ||
| GenTreeHWIntrinsic* tmp0 = | ||
| gtNewSimdHWIntrinsicNode(type, op1, op2, is256 ? NI_AVX2_Multiply : NI_SSE2_Multiply, | ||
| CORINFO_TYPE_ULONG, simdSize); | ||
| // Vector256<uint> tmp1 = Avx2.Shuffle(right.AsUInt32(), ZWXY); | ||
| GenTree* shuffleMask = gtNewIconNode(SHUFFLE_ZWXY, TYP_INT); | ||
| GenTreeHWIntrinsic* tmp1 = gtNewSimdHWIntrinsicNode(type, op2Dup, shuffleMask, | ||
| is256 ? NI_AVX2_Shuffle : NI_SSE2_Shuffle, | ||
| CORINFO_TYPE_UINT, simdSize); | ||
| // Vector256<uint> tmp2 = Avx2.MultiplyLow(left.AsUInt32(), tmp1); | ||
| GenTreeHWIntrinsic* tmp2 = | ||
| gtNewSimdHWIntrinsicNode(type, op1Dup, tmp1, | ||
| is256 ? NI_AVX2_MultiplyLow : NI_SSE41_MultiplyLow, | ||
| CORINFO_TYPE_UINT, simdSize); | ||
| // Vector256<int> tmp3 = Avx2.HorizontalAdd(tmp2.AsInt32(), Vector256<int>.Zero); | ||
| GenTreeHWIntrinsic* tmp3 = | ||
| gtNewSimdHWIntrinsicNode(type, tmp2, gtNewZeroConNode(type), | ||
| is256 ? NI_AVX2_HorizontalAdd : NI_SSSE3_HorizontalAdd, | ||
| CORINFO_TYPE_UINT, simdSize); | ||
Comment on lines +21536 to +21540 Member 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. I know in other places we've started avoiding MemberAuthor 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. I tried to benchmark different implementations for it and they all were equaly fast e.g.#99871 (comment) | ||
| // Vector256<int> tmp4 = Avx2.Shuffle(tmp3, YWXW); | ||
| shuffleMask = gtNewIconNode(SHUFFLE_YWXW, TYP_INT); | ||
| GenTreeHWIntrinsic* tmp4 = | ||
| gtNewSimdHWIntrinsicNode(type, tmp3, shuffleMask, is256 ? NI_AVX2_Shuffle : NI_SSE2_Shuffle, | ||
| CORINFO_TYPE_UINT, simdSize); | ||
| // result = tmp0 + tmp4; | ||
| op1 = tmp0; | ||
| op2 = tmp4; | ||
| intrinsic = simdSize == 32 ? NI_AVX2_Add : NI_SSE2_Add; | ||
| } | ||
| break; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2706,17 +2706,25 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, | ||
| if (varTypeIsLong(simdBaseType)) | ||
| { | ||
| if (TARGET_POINTER_SIZE == 4) | ||
| { | ||
| // TODO-XARCH-CQ:32bitsupport | ||
Member 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. What's blocking 32-bit support? It doesn't look like we're using any MemberAuthor 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. Not sure to be honest, that check was pre-existing, I only changed comment | ||
| break; | ||
| } | ||
| if ((simdSize == 32) && compOpportunisticallyDependsOn(InstructionSet_AVX2)) | ||
| { | ||
| // Emulate NI_AVX512DQ_VL_MultiplyLow with AVX2 for SIMD32 | ||
| } | ||
| else if ((simdSize == 16) && compOpportunisticallyDependsOn(InstructionSet_SSE41)) | ||
| { | ||
| // Emulate NI_AVX512DQ_VL_MultiplyLow with SSE41 for SIMD16 | ||
| } | ||
| else | ||
| { | ||
| // Software fallback | ||
| break; | ||
| } | ||
| } | ||
| CORINFO_ARG_LIST_HANDLE arg1 = sig->args; | ||