Skip to content

Commit 5e219b5

Browse files
modulovaluedart-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[vm] x64: add psrld
Needed to intrinsify Int32x4 operator >>>. Issue: #64170 Issue: #64345 Issue: #64511 TEST=vm/cc/Assembler_PackedShiftRightLogical Change-Id: If231ca838bcff89d1c38f3e4f68ddc5a54c64613 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/560560 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com> Commit-Queue: Slava Egorov <vegorov@google.com>
1 parent 4f8e1e4 commit 5e219b5

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎runtime/vm/compiler/assembler/assembler_x64.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class Assembler : public AssemblerBase {
470470
XX(L, addpl, 0xFE, 0x0F, 0x66)
471471
XX(L, pslld, 0xF2, 0x0F, 0x66)
472472
XX(L, psrad, 0xE2, 0x0F, 0x66)
473+
XX(L, psrld, 0xD2, 0x0F, 0x66)
473474
#undef XX
474475
#undef AX
475476
#undef XA

‎runtime/vm/compiler/assembler/assembler_x64_test.cc‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,6 +4353,33 @@ ASSEMBLER_TEST_RUN(PackedShiftRightArithmetic, test) {
43534353
"ret\n");
43544354
}
43554355

4356+
ASSEMBLER_TEST_GENERATE(PackedShiftRightLogical, assembler) {
4357+
__ movq(RAX, CallingConventions::kArg1Reg);
4358+
__ movups(XMM0, Address(RAX, 0));
4359+
__ movd(XMM1, CallingConventions::kArg2Reg);
4360+
__ psrld(XMM0, XMM1);
4361+
__ movups(Address(RAX, 0), XMM0);
4362+
__ ret();
4363+
}
4364+
4365+
ASSEMBLER_TEST_RUN(PackedShiftRightLogical, test) {
4366+
typedef void (*PackedShiftRightLogicalCode)(uint32_t* data, intptr_t count);
4367+
auto check = [&](intptr_t count, const uint32_t (&expected)[4]) {
4368+
uint32_t data[4] = {0xFFFFFFF8, 8, 0x80000000, 0x7FFFFFFF};
4369+
reinterpret_cast<PackedShiftRightLogicalCode>(test->entry())(data, count);
4370+
for (intptr_t i = 0; i < 4; i++) {
4371+
EXPECT_EQ(expected[i], data[i]);
4372+
}
4373+
};
4374+
check(1, {0x7FFFFFFC, 4, 0x40000000, 0x3FFFFFFF});
4375+
// A count of 32 or more shifts every bit out.
4376+
check(32, {0, 0, 0, 0});
4377+
EXPECT_DISASSEMBLY_ENDS_WITH(
4378+
"psrld xmm0,xmm1\n"
4379+
"movups [rax],xmm0\n"
4380+
"ret\n");
4381+
}
4382+
43564383
ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) {
43574384
static const struct ALIGN16 {
43584385
uint32_t a;

‎runtime/vm/compiler/assembler/disassembler_x86.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,8 @@ int DisassemblerX64::TwoByteOpcodeInstruction(uint8_t* data) {
13941394
mnemonic = "pslld";
13951395
} else if (opcode == 0xE2) {
13961396
mnemonic = "psrad";
1397+
} else if (opcode == 0xD2) {
1398+
mnemonic = "psrld";
13971399
} else {
13981400
UnimplementedInstruction(*data);
13991401
return 1;

0 commit comments

Comments
 (0)