Commit f74d2a90 authored by Zhao Jiazhong's avatar Zhao Jiazhong Committed by Commit Bot

[mips64][wasm-simd] Fix bugs of some wasm-simd operations.

Due to lack of testing environment before, there are some bugs in the
implementations of wasm-simd on mips64 platform, this CL fix them
according to the test on Loongson 3A4000.

Change-Id: I59ab6315987fc94a06cf0bf23754f5c593879532
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2162416
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67413}
parent 74e93186
......@@ -296,11 +296,13 @@ constexpr Register cp = s7;
constexpr Register kScratchReg = s3;
constexpr Register kScratchReg2 = s4;
constexpr DoubleRegister kScratchDoubleReg = f30;
// FPU zero reg is often used to hold 0.0, but it's not hardwired to 0.0.
constexpr DoubleRegister kDoubleRegZero = f28;
// Used on mips64r6 for compare operations.
// We use the last non-callee saved odd register for N64 ABI
constexpr DoubleRegister kDoubleCompareReg = f23;
// MSA zero and scratch regs must have the same numbers as FPU zero and scratch
// MSA zero reg is often used to hold 0, but it's not hardwired to 0.
constexpr Simd128Register kSimd128RegZero = w28;
constexpr Simd128Register kSimd128ScratchReg = w30;
......
......@@ -132,6 +132,20 @@ static void VisitRRI(InstructionSelector* selector, ArchOpcode opcode,
g.UseRegister(node->InputAt(0)), g.UseImmediate(imm));
}
static void VisitSimdShift(InstructionSelector* selector, ArchOpcode opcode,
Node* node) {
Mips64OperandGenerator g(selector);
if (g.IsIntegerConstant(node->InputAt(1))) {
selector->Emit(opcode, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)),
g.UseImmediate(node->InputAt(1)));
} else {
selector->Emit(opcode, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)));
}
}
static void VisitRRIR(InstructionSelector* selector, ArchOpcode opcode,
Node* node) {
Mips64OperandGenerator g(selector);
......@@ -2877,7 +2891,7 @@ void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) {
void InstructionSelector::VisitS128Zero(Node* node) {
Mips64OperandGenerator g(this);
Emit(kMips64S128Zero, g.DefineSameAsFirst(node));
Emit(kMips64S128Zero, g.DefineAsRegister(node));
}
#define SIMD_VISIT_SPLAT(Type) \
......@@ -2917,7 +2931,7 @@ SIMD_UNOP_LIST(SIMD_VISIT_UNOP)
#define SIMD_VISIT_SHIFT_OP(Name) \
void InstructionSelector::Visit##Name(Node* node) { \
VisitRRI(this, kMips64##Name, node); \
VisitSimdShift(this, kMips64##Name, node); \
}
SIMD_SHIFT_OP_LIST(SIMD_VISIT_SHIFT_OP)
#undef SIMD_VISIT_SHIFT_OP
......
......@@ -62,7 +62,7 @@ inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src,
assm->Ldc1(dst.fp(), src);
break;
case ValueType::kS128:
assm->ld_d(dst.fp().toW(), src);
assm->ld_b(dst.fp().toW(), src);
break;
default:
UNREACHABLE();
......@@ -109,7 +109,7 @@ inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) {
break;
case ValueType::kS128:
assm->daddiu(sp, sp, -kSystemPointerSize * 2);
assm->st_d(reg.fp().toW(), MemOperand(sp, 0));
assm->st_b(reg.fp().toW(), MemOperand(sp, 0));
break;
default:
UNREACHABLE();
......@@ -382,7 +382,7 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
TurboAssembler::Uldc1(dst.fp(), src_op, t8);
break;
case LoadType::kS128Load:
TurboAssembler::ld_d(dst.fp().toW(), src_op);
TurboAssembler::ld_b(dst.fp().toW(), src_op);
break;
default:
UNREACHABLE();
......@@ -448,7 +448,7 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
TurboAssembler::Usdc1(src.fp(), dst_op, t8);
break;
case StoreType::kS128Store:
TurboAssembler::st_d(src.fp().toW(), dst_op);
TurboAssembler::st_b(src.fp().toW(), dst_op);
break;
default:
UNREACHABLE();
......@@ -561,7 +561,7 @@ void LiftoffAssembler::Spill(int offset, LiftoffRegister reg, ValueType type) {
TurboAssembler::Sdc1(reg.fp(), dst);
break;
case ValueType::kS128:
TurboAssembler::st_d(reg.fp().toW(), dst);
TurboAssembler::st_b(reg.fp().toW(), dst);
break;
default:
UNREACHABLE();
......@@ -607,7 +607,7 @@ void LiftoffAssembler::Fill(LiftoffRegister reg, int offset, ValueType type) {
TurboAssembler::Ldc1(reg.fp(), src);
break;
case ValueType::kS128:
TurboAssembler::ld_d(reg.fp().toW(), src);
TurboAssembler::ld_b(reg.fp().toW(), src);
break;
default:
UNREACHABLE();
......
......@@ -1215,7 +1215,8 @@ WASM_SIMD_TEST_NO_LOWERING(F64x2ReplaceLane) {
CHECK_EQ(1., ReadLittleEndianValue<double>(&g1[1]));
}
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X || \
V8_TARGET_ARCH_MIPS64
WASM_SIMD_TEST_NO_LOWERING(F64x2ExtractLaneWithI64x2) {
WasmRunner<int64_t> r(execution_tier, lower_simd);
BUILD_V(r, WASM_IF_ELSE_L(
......@@ -1235,7 +1236,8 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2ExtractWithF64x2) {
WASM_I64V(1), WASM_I64V(0)));
CHECK_EQ(1, r.Call());
}
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X ||
// V8_TARGET_ARCH_MIPS64
bool IsExtreme(double x) {
double abs_x = std::fabs(x);
......@@ -3555,8 +3557,6 @@ WASM_SIMD_TEST_NO_LOWERING(I64x2Load32x2S) {
kExprI64x2Load32x2S);
}
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 || \
V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_S390X
#define WASM_SIMD_ANYTRUE_TEST(format, lanes, max, param_type) \
WASM_SIMD_TEST(S##format##AnyTrue) { \
FLAG_SCOPE(wasm_simd_post_mvp); \
......@@ -3598,8 +3598,6 @@ WASM_SIMD_ALLTRUE_TEST(64x2, 2, 0xffffffffffffffff, int64_t)
WASM_SIMD_ALLTRUE_TEST(32x4, 4, 0xffffffff, int32_t)
WASM_SIMD_ALLTRUE_TEST(16x8, 8, 0xffff, int32_t)
WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff, int32_t)
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 ||
// V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_S390X
WASM_SIMD_TEST(BitSelect) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
......
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