Commit 8b26bd2c authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[mips][wasm][liftoff] Implement s128_set_if_nan in liftoff

Besides, fix an error in set_if_nan, because if src is a NaN, we should
set the i32 instead of i64 at address dst to a non-zero value.

Port e6961df2

Bug: v8:11856

Change-Id: Icc9afda35d4cca4fd5ae82356ecaec77bf92d009
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3139055Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu yu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#76636}
parent ed6058c6
...@@ -2750,15 +2750,17 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src, ...@@ -2750,15 +2750,17 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src,
ValueKind kind) { ValueKind kind) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
li(scratch, 1); Label not_nan;
if (kind == kF32) { if (kind == kF32) {
CompareIsNanF32(src, src); CompareIsNanF32(src, src);
} else { } else {
DCHECK_EQ(kind, kF64); DCHECK_EQ(kind, kF64);
CompareIsNanF64(src, src); CompareIsNanF64(src, src);
} }
LoadZeroIfNotFPUCondition(scratch); BranchFalseShortF(&not_nan);
St_d(scratch, MemOperand(dst, 0)); li(scratch, 1);
St_w(scratch, MemOperand(dst, 0));
bind(&not_nan);
} }
void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src, void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src,
......
...@@ -3067,15 +3067,17 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src, ...@@ -3067,15 +3067,17 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src,
ValueKind kind) { ValueKind kind) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
li(scratch, 1); Label not_nan;
if (kind == kF32) { if (kind == kF32) {
CompareIsNanF32(src, src); CompareIsNanF32(src, src);
} else { } else {
DCHECK_EQ(kind, kF64); DCHECK_EQ(kind, kF64);
CompareIsNanF64(src, src); CompareIsNanF64(src, src);
} }
LoadZeroIfNotFPUCondition(scratch); BranchFalseShortF(&not_nan, USE_DELAY_SLOT);
Sw(scratch, MemOperand(dst)); li(scratch, 1);
sw(scratch, MemOperand(dst));
bind(&not_nan);
} }
void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src, void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src,
......
...@@ -3235,22 +3235,35 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src, ...@@ -3235,22 +3235,35 @@ void LiftoffAssembler::emit_set_if_nan(Register dst, FPURegister src,
ValueKind kind) { ValueKind kind) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
li(scratch, 1); Label not_nan;
if (kind == kF32) { if (kind == kF32) {
CompareIsNanF32(src, src); CompareIsNanF32(src, src);
} else { } else {
DCHECK_EQ(kind, kF64); DCHECK_EQ(kind, kF64);
CompareIsNanF64(src, src); CompareIsNanF64(src, src);
} }
LoadZeroIfNotFPUCondition(scratch); BranchFalseShortF(&not_nan, USE_DELAY_SLOT);
Sd(scratch, MemOperand(dst)); li(scratch, 1);
Sw(dst, MemOperand(dst));
bind(&not_nan);
} }
void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src, void LiftoffAssembler::emit_s128_set_if_nan(Register dst, LiftoffRegister src,
Register tmp_gp, Register tmp_gp,
LiftoffRegister tmp_s128, LiftoffRegister tmp_s128,
ValueKind lane_kind) { ValueKind lane_kind) {
UNIMPLEMENTED(); Label not_nan;
if (lane_kind == kF32) {
fcun_w(tmp_s128.fp().toW(), src.fp().toW(), src.fp().toW());
} else {
DCHECK_EQ(lane_kind, kF64);
fcun_d(tmp_s128.fp().toW(), src.fp().toW(), src.fp().toW());
}
BranchMSA(&not_nan, MSA_BRANCH_V, all_zero, tmp_s128.fp().toW(),
USE_DELAY_SLOT);
li(tmp_gp, 1);
Sw(tmp_gp, MemOperand(dst));
bind(&not_nan);
} }
void LiftoffStackSlots::Construct(int param_slots) { void LiftoffStackSlots::Construct(int param_slots) {
......
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