Skip to content

Commit

Permalink
JIT: Fix embedded broadcast simd size (#111638)
Browse files Browse the repository at this point in the history
This ensures that when a constant vector is replaced with a broadcast node, the replacement node is of the correct size.  Since only the scalar is read from the broadcast node, SIMD size doesn't really matter for codegen, but this fix satisfies the assert in #111613 by ensuring we replace like for like.
  • Loading branch information
saucecontrol authored Jan 26, 2025
1 parent 0f0753d commit 843f798
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9602,21 +9602,23 @@ void Lowering::TryFoldCnsVecForEmbeddedBroadcast(GenTreeHWIntrinsic* parentNode,
{
assert(!childNode->IsAllBitsSet());
assert(!childNode->IsZero());
var_types simdType = parentNode->TypeGet();
var_types simdBaseType = parentNode->GetSimdBaseType();
CorInfoType simdBaseJitType = parentNode->GetSimdBaseJitType();
bool isCreatedFromScalar = true;

if (!comp->canUseEmbeddedBroadcast())
{
MakeSrcContained(parentNode, childNode);
return;
}

if (simdType == TYP_MASK)
{
simdType = Compiler::getSIMDTypeForSize(parentNode->GetSimdSize());
}
// We use the child node's size for the broadcast node, because the parent may consume more than its own size.
// The containment check has already validated that the child is sufficiently large.
//
// We use the parent node's base type, because we must ensure that the constant repeats correctly for that size,
// regardless of how the constant vector was created.

var_types simdType = childNode->TypeGet();
var_types simdBaseType = parentNode->GetSimdBaseType();
CorInfoType simdBaseJitType = parentNode->GetSimdBaseJitType();
bool isCreatedFromScalar = true;

if (varTypeIsSmall(simdBaseType))
{
Expand Down

0 comments on commit 843f798

Please sign in to comment.