Skip to content

Commit 3eae1a6

Browse files
committed
Fixing the handling of Vector512.CreateScalar
1 parent c993845 commit 3eae1a6

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/coreclr/jit/lowerxarch.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,24 +3551,34 @@ GenTree* Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
35513551
}
35523552
}
35533553

3554-
if (simdSize == 32)
3554+
if (simdSize > 16)
35553555
{
3556-
// We're creating a Vector256 scalar so we need to treat the original op as Vector128,
3557-
// we need to unsafely extend up to Vector256 (which is actually safe since the 128-bit
3558-
// op will zero extend up to 256-bits), and then we need to replace the original use
3559-
// with the new TYP_SIMD32 node.
3556+
assert((simdSize == 32) || (simdSize == 64));
3557+
3558+
// We're creating a Vector256/512 scalar so we need to treat the original op as Vector128,
3559+
// we need to unsafely extend up to Vector256/512 (which is actually safe since the 128-bit
3560+
// op will zero extend up to 256/512-bits), and then we need to replace the original use
3561+
// with the new TYP_SIMD32/64 node.
35603562

35613563
node->ChangeType(TYP_SIMD16);
35623564
node->SetSimdSize(16);
35633565
LowerNode(node);
35643566

3565-
tmp2 = comp->gtNewSimdHWIntrinsicNode(TYP_SIMD32, node, NI_Vector128_ToVector256Unsafe, simdBaseJitType,
3566-
16);
3567-
35683567
LIR::Use use;
35693568
bool foundUse = BlockRange().TryGetUse(node, &use);
3569+
3570+
tmp2 = comp->gtNewSimdHWIntrinsicNode(TYP_SIMD32, node, NI_Vector128_ToVector256Unsafe, simdBaseJitType,
3571+
16);
35703572
BlockRange().InsertAfter(node, tmp2);
35713573

3574+
if (simdSize == 64)
3575+
{
3576+
tmp3 = comp->gtNewSimdHWIntrinsicNode(TYP_SIMD64, tmp2, NI_Vector256_ToVector512Unsafe,
3577+
simdBaseJitType, 32);
3578+
BlockRange().InsertAfter(tmp2, tmp3);
3579+
tmp2 = tmp3;
3580+
}
3581+
35723582
if (foundUse)
35733583
{
35743584
use.ReplaceWith(tmp2);

0 commit comments

Comments
 (0)