Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29356,6 +29356,9 @@ GenTree* Compiler::gtNewSimdShuffleNode(
uint64_t value = 0;
simd_t vecCns = {};

// i8x16.swizzle indexes bytes, so expand each element-granular selector into elementSize
// consecutive byte indices. An out-of-range selector becomes 0xFF bytes so swizzle's native
// "index >= 16 -> 0" behavior zero-fills that element.
for (size_t index = 0; index < elementCount; index++)
{
value = op2->GetIntegralVectorConstElement(index, simdBaseType);
Expand All @@ -29369,8 +29372,6 @@ GenTree* Compiler::gtNewSimdShuffleNode(
}
else
{
// Swizzle selects zero for any byte index that is out of range (>= 16), so mark every
// byte of an out-of-range element accordingly.
for (uint32_t i = 0; i < elementSize; i++)
{
vecCns.u8[(index * elementSize) + i] = 0xFF;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/hwintrinsiccodegenwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
if ((info.id == NI_PackedSimd_Swizzle) && node->Op(2)->isContained())
{
// A constant, fully in-range mask was lowered to an immediate i8x16.shuffle.
// genConsumeMultiOpOperands left the source on the value stack once (the mask
// prior codegen left the source on the value stack once (the mask
// operand is contained, so no v128.const was materialized). i8x16.shuffle
Comment thread
tannergooding marked this conversation as resolved.
// selects from two vectors, so push the source a second time and encode the
// mask as the 16-byte shuffle immediate.
Expand Down
Loading