commit 8eb9bf1bcb2416ff1e47dc99f1b7829b78be34fb
parent d7601d1e5583c8ab48bfa8f91596e3ab10be1bce
Author: André Bargull <andre.bargull@gmail.com>
Date: Mon, 20 Oct 2025 08:20:23 +0000
Bug 1993951 - Part 6: Move CopySign into shared code generator. r=spidermonkey-reviewers,iain
And remove no longer used temp registers.
Differential Revision: https://phabricator.services.mozilla.com/D268371
Diffstat:
17 files changed, 42 insertions(+), 122 deletions(-)
diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp
@@ -12784,6 +12784,36 @@ void CodeGenerator::visitRoundToFloat32(LRoundToFloat32* lir) {
masm.roundFloat32(input, output);
}
+void CodeGenerator::visitCopySignF(LCopySignF* lir) {
+ FloatRegister lhs = ToFloatRegister(lir->lhs());
+ FloatRegister rhs = ToFloatRegister(lir->rhs());
+ FloatRegister out = ToFloatRegister(lir->output());
+
+ if (lhs == rhs) {
+ if (lhs != out) {
+ masm.moveFloat32(lhs, out);
+ }
+ return;
+ }
+
+ masm.copySignFloat32(lhs, rhs, out);
+}
+
+void CodeGenerator::visitCopySignD(LCopySignD* lir) {
+ FloatRegister lhs = ToFloatRegister(lir->lhs());
+ FloatRegister rhs = ToFloatRegister(lir->rhs());
+ FloatRegister out = ToFloatRegister(lir->output());
+
+ if (lhs == rhs) {
+ if (lhs != out) {
+ masm.moveDouble(lhs, out);
+ }
+ return;
+ }
+
+ masm.copySignDouble(lhs, rhs, out);
+}
+
void CodeGenerator::visitCompareS(LCompareS* lir) {
JSOp op = lir->mir()->jsop();
Register left = ToRegister(lir->left());
diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml
@@ -1156,7 +1156,6 @@
operands:
lhs: WordSized
rhs: WordSized
- num_temps: 2
defer_init: true
# Copysign for float32.
@@ -1165,7 +1164,6 @@
operands:
lhs: WordSized
rhs: WordSized
- num_temps: 2
defer_init: true
# Count leading zeroes on an int32.
diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h
@@ -1328,8 +1328,7 @@ class MacroAssembler : public MacroAssemblerSpecific {
void copySignDouble(FloatRegister lhs, FloatRegister rhs,
FloatRegister output) PER_SHARED_ARCH;
void copySignFloat32(FloatRegister lhs, FloatRegister rhs,
- FloatRegister output)
- DEFINED_ON(arm, arm64, loong64, mips64, riscv64, x86_shared);
+ FloatRegister output) PER_SHARED_ARCH;
// Returns a random double in range [0, 1) in |dest|. The |rng| register must
// hold a pointer to a mozilla::non_crypto::XorShift128PlusRNG.
diff --git a/js/src/jit/arm/CodeGenerator-arm.cpp b/js/src/jit/arm/CodeGenerator-arm.cpp
@@ -2361,22 +2361,6 @@ void CodeGenerator::visitInt64ToFloatingPointCall(
masm.Pop(InstanceReg);
}
-void CodeGenerator::visitCopySignF(LCopySignF* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignFloat32(lhs, rhs, output);
-}
-
-void CodeGenerator::visitCopySignD(LCopySignD* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignDouble(lhs, rhs, output);
-}
-
void CodeGenerator::visitWrapInt64ToInt32(LWrapInt64ToInt32* lir) {
LInt64Allocation input = lir->input();
Register output = ToRegister(lir->output());
diff --git a/js/src/jit/arm/Lowering-arm.cpp b/js/src/jit/arm/Lowering-arm.cpp
@@ -1138,7 +1138,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {
diff --git a/js/src/jit/arm64/CodeGenerator-arm64.cpp b/js/src/jit/arm64/CodeGenerator-arm64.cpp
@@ -2151,20 +2151,6 @@ void CodeGenerator::visitWasmLoad(LWasmLoad* lir) {
ToRegister(lir->ptr()), ToAnyRegister(lir->output()));
}
-void CodeGenerator::visitCopySignD(LCopySignD* ins) {
- MOZ_ASSERT(ins->temp0()->isBogusTemp());
- MOZ_ASSERT(ins->temp1()->isBogusTemp());
- masm.copySignDouble(ToFloatRegister(ins->lhs()), ToFloatRegister(ins->rhs()),
- ToFloatRegister(ins->output()));
-}
-
-void CodeGenerator::visitCopySignF(LCopySignF* ins) {
- MOZ_ASSERT(ins->temp0()->isBogusTemp());
- MOZ_ASSERT(ins->temp1()->isBogusTemp());
- masm.copySignFloat32(ToFloatRegister(ins->lhs()), ToFloatRegister(ins->rhs()),
- ToFloatRegister(ins->output()));
-}
-
void CodeGenerator::visitWasmStore(LWasmStore* lir) {
const MWasmStore* mir = lir->mir();
diff --git a/js/src/jit/arm64/Lowering-arm64.cpp b/js/src/jit/arm64/Lowering-arm64.cpp
@@ -959,7 +959,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {
diff --git a/js/src/jit/loong64/CodeGenerator-loong64.cpp b/js/src/jit/loong64/CodeGenerator-loong64.cpp
@@ -1582,22 +1582,6 @@ void CodeGenerator::visitWasmTruncateToInt32(LWasmTruncateToInt32* lir) {
masm.bind(ool->rejoin());
}
-void CodeGenerator::visitCopySignF(LCopySignF* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignFloat32(lhs, rhs, output);
-}
-
-void CodeGenerator::visitCopySignD(LCopySignD* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignDouble(lhs, rhs, output);
-}
-
void CodeGenerator::visitTestDAndBranch(LTestDAndBranch* test) {
FloatRegister input = ToFloatRegister(test->input());
ScratchDoubleScope fpscratch(masm);
diff --git a/js/src/jit/loong64/Lowering-loong64.cpp b/js/src/jit/loong64/Lowering-loong64.cpp
@@ -545,7 +545,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {
diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
@@ -1110,22 +1110,6 @@ void CodeGeneratorMIPSShared::visitOutOfLineWasmTruncateCheck(
}
}
-void CodeGenerator::visitCopySignF(LCopySignF* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignFloat32(lhs, rhs, output);
-}
-
-void CodeGenerator::visitCopySignD(LCopySignD* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignDouble(lhs, rhs, output);
-}
-
void CodeGenerator::visitTestDAndBranch(LTestDAndBranch* test) {
FloatRegister input = ToFloatRegister(test->input());
diff --git a/js/src/jit/mips-shared/Lowering-mips-shared.cpp b/js/src/jit/mips-shared/Lowering-mips-shared.cpp
@@ -827,7 +827,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {
diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp
@@ -1669,22 +1669,6 @@ void CodeGenerator::visitWasmTruncateToInt32(LWasmTruncateToInt32* lir) {
MOZ_ASSERT(!ool || !ool->rejoin()->bound(), "ool path doesn't return");
}
-void CodeGenerator::visitCopySignF(LCopySignF* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignFloat32(lhs, rhs, output);
-}
-
-void CodeGenerator::visitCopySignD(LCopySignD* ins) {
- FloatRegister lhs = ToFloatRegister(ins->lhs());
- FloatRegister rhs = ToFloatRegister(ins->rhs());
- FloatRegister output = ToFloatRegister(ins->output());
-
- masm.copySignDouble(lhs, rhs, output);
-}
-
void CodeGenerator::visitTestDAndBranch(LTestDAndBranch* test) {
FloatRegister input = ToFloatRegister(test->input());
ScratchDoubleScope fpscratch(masm);
diff --git a/js/src/jit/riscv64/Lowering-riscv64.cpp b/js/src/jit/riscv64/Lowering-riscv64.cpp
@@ -545,7 +545,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {
diff --git a/js/src/jit/wasm32/CodeGenerator-wasm32.cpp b/js/src/jit/wasm32/CodeGenerator-wasm32.cpp
@@ -37,8 +37,6 @@ void CodeGenerator::visitNegI(LNegI* ins) { MOZ_CRASH(); }
void CodeGenerator::visitNegI64(LNegI64* ins) { MOZ_CRASH(); }
void CodeGenerator::visitNegD(LNegD* ins) { MOZ_CRASH(); }
void CodeGenerator::visitNegF(LNegF* ins) { MOZ_CRASH(); }
-void CodeGenerator::visitCopySignD(LCopySignD* ins) { MOZ_CRASH(); }
-void CodeGenerator::visitCopySignF(LCopySignF* ins) { MOZ_CRASH(); }
void CodeGenerator::visitAddI(LAddI* ins) { MOZ_CRASH(); }
void CodeGenerator::visitAddIntPtr(LAddIntPtr* ins) { MOZ_CRASH(); }
void CodeGenerator::visitAddI64(LAddI64* lir) { MOZ_CRASH(); }
diff --git a/js/src/jit/wasm32/MacroAssembler-wasm32.cpp b/js/src/jit/wasm32/MacroAssembler-wasm32.cpp
@@ -395,6 +395,11 @@ void MacroAssembler::copySignDouble(FloatRegister lhs, FloatRegister rhs,
MOZ_CRASH();
}
+void MacroAssembler::copySignFloat32(FloatRegister lhs, FloatRegister rhs,
+ FloatRegister output) {
+ MOZ_CRASH();
+}
+
void MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs,
const Value& rhs, Label* label) {
MOZ_CRASH();
diff --git a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp
@@ -2018,38 +2018,6 @@ Operand CodeGeneratorX86Shared::toMemoryAccessOperand(T* lir, int32_t disp) {
return destAddr;
}
-void CodeGenerator::visitCopySignF(LCopySignF* lir) {
- FloatRegister lhs = ToFloatRegister(lir->lhs());
- FloatRegister rhs = ToFloatRegister(lir->rhs());
-
- FloatRegister out = ToFloatRegister(lir->output());
-
- if (lhs == rhs) {
- if (lhs != out) {
- masm.moveFloat32(lhs, out);
- }
- return;
- }
-
- masm.copySignFloat32(lhs, rhs, out);
-}
-
-void CodeGenerator::visitCopySignD(LCopySignD* lir) {
- FloatRegister lhs = ToFloatRegister(lir->lhs());
- FloatRegister rhs = ToFloatRegister(lir->rhs());
-
- FloatRegister out = ToFloatRegister(lir->output());
-
- if (lhs == rhs) {
- if (lhs != out) {
- masm.moveDouble(lhs, out);
- }
- return;
- }
-
- masm.copySignDouble(lhs, rhs, out);
-}
-
void CodeGenerator::visitSimd128(LSimd128* ins) {
#ifdef ENABLE_WASM_SIMD
const LDefinition* out = ins->output();
diff --git a/js/src/jit/x86-shared/Lowering-x86-shared.cpp b/js/src/jit/x86-shared/Lowering-x86-shared.cpp
@@ -749,7 +749,7 @@ void LIRGenerator::visitCopySign(MCopySign* ins) {
MOZ_ASSERT(lhs->type() == rhs->type());
MOZ_ASSERT(lhs->type() == ins->type());
- LInstructionHelper<1, 2, 2>* lir;
+ LInstructionHelper<1, 2, 0>* lir;
if (lhs->type() == MIRType::Double) {
lir = new (alloc()) LCopySignD();
} else {