Repository navigation
Upgrading Vector256/512 Shuffle() with VBMI support #87083
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -23322,7 +23322,7 @@ GenTree* Compiler::gtNewSimdShuffleNode( | |
| #if defined(TARGET_XARCH) | ||
| uint8_t control = 0; | ||
| bool crossLane = false; | ||
| bool needsZero = varTypeIsSmallInt(simdBaseType) && (simdSize != 64); | ||
| bool needsZero = varTypeIsSmallInt(simdBaseType) && (simdSize <= 16); | ||
| uint64_t value = 0; | ||
| simd_t vecCns = {}; | ||
| simd_t mskCns = {}; | ||
|
|
@@ -23395,7 +23395,8 @@ GenTree* Compiler::gtNewSimdShuffleNode( | |
| { | ||
| assert(compIsaSupportedDebugOnly(InstructionSet_AVX2)); | ||
|
|
||
| if (varTypeIsSmallInt(simdBaseType)) | ||
| if ((varTypeIsByte(simdBaseType) && !compOpportunisticallyDependsOn(InstructionSet_AVX512VBMI_VL)) || | ||
| (varTypeIsShort(simdBaseType) && !compOpportunisticallyDependsOn(InstructionSet_AVX512BW_VL))) | ||
| { | ||
| if (crossLane) | ||
| { | ||
|
|
@@ -23448,6 +23449,31 @@ GenTree* Compiler::gtNewSimdShuffleNode( | |
| // swap the operands to match the encoding requirements | ||
| retNode = gtNewSimdHWIntrinsicNode(type, op2, op1, NI_AVX2_PermuteVar8x32, simdBaseJitType, simdSize); | ||
| } | ||
| else if (elementSize == 2) | ||
| { | ||
|
tannergooding marked this conversation as resolved.
Resolved
|
||
| assert(compIsaSupportedDebugOnly(InstructionSet_AVX512BW_VL)); | ||
| for (uint32_t i = 0; i < elementCount; i++) | ||
| { | ||
| vecCns.u16[i] = (uint8_t)(vecCns.u8[i * elementSize] / elementSize); | ||
| } | ||
|
|
||
| op2 = gtNewVconNode(type); | ||
| op2->AsVecCon()->gtSimdVal = vecCns; | ||
|
|
||
| // swap the operands to match the encoding requirements | ||
| retNode = | ||
| gtNewSimdHWIntrinsicNode(type, op2, op1, NI_AVX512BW_VL_PermuteVar16x16, simdBaseJitType, simdSize); | ||
| } | ||
| else if (elementSize == 1) | ||
| { | ||
| assert(compIsaSupportedDebugOnly(InstructionSet_AVX512VBMI_VL)); | ||
| op2 = gtNewVconNode(type); | ||
| op2->AsVecCon()->gtSimdVal = vecCns; | ||
|
|
||
| // swap the operands to match the encoding requirements | ||
| retNode = | ||
| gtNewSimdHWIntrinsicNode(type, op2, op1, NI_AVX512VBMI_VL_PermuteVar32x8, simdBaseJitType, simdSize); | ||
| } | ||
| else | ||
| { | ||
| assert(elementSize == 8); | ||
|
|
@@ -23458,6 +23484,7 @@ GenTree* Compiler::gtNewSimdShuffleNode( | |
| } | ||
| else if (simdSize == 64) | ||
| { | ||
| assert(IsBaselineVector512IsaSupportedDebugOnly()); | ||
| if (elementSize == 4) | ||
| { | ||
| for (uint32_t i = 0; i < elementCount; i++) | ||
|
|
@@ -23484,6 +23511,15 @@ GenTree* Compiler::gtNewSimdShuffleNode( | |
| // swap the operands to match the encoding requirements | ||
| retNode = gtNewSimdHWIntrinsicNode(type, op2, op1, NI_AVX512BW_PermuteVar32x16, simdBaseJitType, simdSize); | ||
| } | ||
| else if (elementSize == 1) | ||
|
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. There's potentially a missing "todo" here to handle this using I don't think it needs to be handled as part of this PR (or even for .NET 8 necessarily) since that scenario should only be limited to pre-cannon lake (and therefore first generation AVX-512 hardware). But, since it should just be refactoring the logic under the |
||
| { | ||
| assert(compIsaSupportedDebugOnly(InstructionSet_AVX512VBMI)); | ||
| op2 = gtNewVconNode(type); | ||
| op2->AsVecCon()->gtSimdVal = vecCns; | ||
|
|
||
| // swap the operands to match the encoding requirements | ||
| retNode = gtNewSimdHWIntrinsicNode(type, op2, op1, NI_AVX512VBMI_PermuteVar64x8, simdBaseJitType, simdSize); | ||
| } | ||
|
tannergooding marked this conversation as resolved.
Resolved
|
||
| else | ||
| { | ||
| assert(elementSize == 8); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.