Commit 4903f94c authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips64] Optimizing the swap between FPStackSlot and FPStackSlot

Use doubleword load/store to swap values in FPSackSlots instead of word
load/store.
Besides, fix error in gap resolver.

Change-Id: I57e9d577a6001bc970ce6b56b6f890eb3e4d196c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3688325
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#80971}
parent c202e301
......@@ -2549,17 +2549,27 @@ void CodeGenerator::SetPendingMove(MoveOperands* move) {
Loong64OperandConverter g(this, nullptr);
bool src_need_scratch = false;
bool dst_need_scratch = false;
if (src->IsAnyStackSlot()) {
if (src->IsStackSlot()) {
// Doubleword load/store
MemOperand src_mem = g.ToMemOperand(src);
src_need_scratch =
(!is_int16(src_mem.offset()) || (src_mem.offset() & 0b11) != 0) &&
(!is_int12(src_mem.offset()) && !src_mem.hasIndexReg());
} else if (src->IsFPStackSlot()) {
// DoubleWord float-pointing load/store.
MemOperand src_mem = g.ToMemOperand(src);
src_need_scratch = !is_int12(src_mem.offset()) && !src_mem.hasIndexReg();
}
if (dst->IsAnyStackSlot()) {
if (dst->IsStackSlot()) {
// Doubleword load/store
MemOperand dst_mem = g.ToMemOperand(dst);
dst_need_scratch =
(!is_int16(dst_mem.offset()) || (dst_mem.offset() & 0b11) != 0) &&
(!is_int12(dst_mem.offset()) && !dst_mem.hasIndexReg());
} else if (dst->IsFPStackSlot()) {
// DoubleWord float-pointing load/store.
MemOperand dst_mem = g.ToMemOperand(dst);
dst_need_scratch = !is_int12(dst_mem.offset()) && !dst_mem.hasIndexReg();
}
if (src_need_scratch || dst_need_scratch) {
Register temp = temps.Acquire();
......@@ -2746,17 +2756,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
DCHECK(destination->IsFPStackSlot());
UseScratchRegisterScope temps(tasm());
Register scratch = temps.Acquire();
MemOperand src0 = g.ToMemOperand(source);
MemOperand src1(src0.base(), src0.offset() + kIntSize);
MemOperand dst0 = g.ToMemOperand(destination);
MemOperand dst1(dst0.base(), dst0.offset() + kIntSize);
FPURegister scratch_d = kScratchDoubleReg;
__ Fld_d(scratch_d, dst0); // Save destination in temp_1.
__ Ld_w(scratch, src0); // Then use scratch to copy source to destination.
__ St_w(scratch, dst0);
__ Ld_w(scratch, src1);
__ St_w(scratch, dst1);
__ Fst_d(scratch_d, src0);
MemOperand src = g.ToMemOperand(source);
MemOperand dst = g.ToMemOperand(destination);
__ Fld_d(scratch_d, src);
__ Ld_d(scratch, dst);
__ Fst_d(scratch_d, dst);
__ St_d(scratch, src);
} else {
// No other combinations are possible.
UNREACHABLE();
......
......@@ -4679,35 +4679,25 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
DCHECK(destination->IsFPStackSlot());
Register temp_0 = kScratchReg;
MemOperand src0 = g.ToMemOperand(source);
MemOperand src1(src0.rm(), src0.offset() + kIntSize);
MemOperand src1(src0.rm(), src0.offset() + kInt64Size);
MemOperand dst0 = g.ToMemOperand(destination);
MemOperand dst1(dst0.rm(), dst0.offset() + kIntSize);
MemOperand dst1(dst0.rm(), dst0.offset() + kInt64Size);
MachineRepresentation rep = LocationOperand::cast(source)->representation();
if (rep == MachineRepresentation::kSimd128) {
MemOperand src2(src0.rm(), src0.offset() + 2 * kIntSize);
MemOperand src3(src0.rm(), src0.offset() + 3 * kIntSize);
MemOperand dst2(dst0.rm(), dst0.offset() + 2 * kIntSize);
MemOperand dst3(dst0.rm(), dst0.offset() + 3 * kIntSize);
CpuFeatureScope msa_scope(tasm(), MIPS_SIMD);
MSARegister temp_1 = kSimd128ScratchReg;
__ ld_b(temp_1, dst0); // Save destination in temp_1.
__ Lw(temp_0, src0); // Then use temp_0 to copy source to destination.
__ Sw(temp_0, dst0);
__ Lw(temp_0, src1);
__ Sw(temp_0, dst1);
__ Lw(temp_0, src2);
__ Sw(temp_0, dst2);
__ Lw(temp_0, src3);
__ Sw(temp_0, dst3);
__ Ld(temp_0, src0); // Then use temp_0 to copy source to destination.
__ Sd(temp_0, dst0);
__ Ld(temp_0, src1);
__ Sd(temp_0, dst1);
__ st_b(temp_1, src0);
} else {
FPURegister temp_1 = kScratchDoubleReg;
__ Ldc1(temp_1, dst0); // Save destination in temp_1.
__ Lw(temp_0, src0); // Then use temp_0 to copy source to destination.
__ Sw(temp_0, dst0);
__ Lw(temp_0, src1);
__ Sw(temp_0, dst1);
__ Ld(temp_0, src0); // Then use temp_0 to copy source to destination.
__ Sdc1(temp_1, src0);
__ Sd(temp_0, dst0);
}
} else {
// No other combinations are possible.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment