Skip to content

Commit

Permalink
Repair very old merge damage and update comments (dotnet#104052)
Browse files Browse the repository at this point in the history
Restore missing or opcode for 2/4-byte shuffles with unknown-at-compile-time shuffle mask in the jiterpreter
  • Loading branch information
kg committed Jun 28, 2024
1 parent 06a208f commit d6f4bee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3858,15 +3858,19 @@ function emit_shuffle (builder: WasmBuilder, ip: MintOpcodePtr, elementCount: nu
builder.appendU8(i);
}
builder.appendSimd(WasmSimdOpcode.i8x16_swizzle);
// multiply indices by 2 to scale from char indices to byte indices
// multiply indices by 2 or 4 to scale from elt indices to byte indices
builder.i32_const(elementCount === 4 ? 2 : 1);
builder.appendSimd(WasmSimdOpcode.i8x16_shl);
// now add 1 to the secondary lane of each char
// now add an offset to the additional bytes of each lane, i.e.
// 0 1 2 3 0 1 2 3 ...
builder.appendSimd(WasmSimdOpcode.v128_const);
for (let i = 0; i < elementCount; i++) {
for (let j = 0; j < elementSize; j++)
builder.appendU8(j);
}
// we can do a bitwise or since we know we previously multiplied all the lanes by 2 or 4,
// so the 1 and 2 bits are already clear
builder.appendSimd(WasmSimdOpcode.v128_or);
}
// we now have two vectors on the stack, the values and the byte indices
builder.appendSimd(WasmSimdOpcode.i8x16_swizzle);
Expand Down

0 comments on commit d6f4bee

Please sign in to comment.