commit c6f2c7e54a4ab1229d9c37801c473610becc33ea
parent 412b9a4602fd9792832b093fc42784134ba97756
Author: André Bargull <andre.bargull@gmail.com>
Date: Fri, 24 Oct 2025 14:58:54 +0000
Bug 1996085 - Part 2: Call lowerForALUInt64 for LNegI64. r=spidermonkey-reviewers,jandem
Differential Revision: https://phabricator.services.mozilla.com/D269841
Diffstat:
16 files changed, 6 insertions(+), 43 deletions(-)
diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml
@@ -1119,6 +1119,7 @@
result_type: Int64
operands:
input: Int64
+ defer_init: true
# Negative of double
- name: NegD
diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp
@@ -2320,7 +2320,7 @@ void LIRGenerator::visitSub(MSub* ins) {
// If our LHS is a constant 0, we can optimize to an LNegI64.
if (lhs->isConstant() && lhs->toConstant()->toInt64() == 0) {
- lowerNegI64(ins, rhs);
+ lowerForALUInt64(new (alloc()) LNegI64, ins, rhs);
return;
}
@@ -2380,7 +2380,7 @@ void LIRGenerator::visitMul(MMul* ins) {
// If our RHS is a constant -1, we can optimize to an LNegI64.
if (rhs->isConstant() && rhs->toConstant()->toInt64() == -1) {
- lowerNegI64(ins, lhs);
+ lowerForALUInt64(new (alloc()) LNegI64, ins, lhs);
return;
}
diff --git a/js/src/jit/arm/Lowering-arm.cpp b/js/src/jit/arm/Lowering-arm.cpp
@@ -182,6 +182,9 @@ void LIRGeneratorARM::lowerForALU(LInstructionHelper<1, 2, 0>* ins,
void LIRGeneratorARM::lowerForALUInt64(
LInstructionHelper<INT64_PIECES, INT64_PIECES, 0>* ins, MDefinition* mir,
MDefinition* input) {
+ // Reuse the input. Define + use-at-start would create risk that the output
+ // uses the same register pair as the input but in reverse order. Reusing
+ // probably has less spilling than the alternative, define + use.
ins->setInt64Operand(0, useInt64RegisterAtStart(input));
defineInt64ReuseInput(ins, mir, 0);
}
@@ -352,14 +355,6 @@ void LIRGeneratorARM::lowerDivI(MDiv* div) {
defineReturn(lir, div);
}
-void LIRGeneratorARM::lowerNegI64(MInstruction* ins, MDefinition* input) {
- // Reuse the input. Define + use-at-start would create risk that the output
- // uses the same register pair as the input but in reverse order. Reusing
- // probably has less spilling than the alternative, define + use.
- defineInt64ReuseInput(new (alloc()) LNegI64(useInt64RegisterAtStart(input)),
- ins, 0);
-}
-
void LIRGenerator::visitAbs(MAbs* ins) {
define(allocateAbs(ins, useRegisterAtStart(ins->input())), ins);
}
diff --git a/js/src/jit/arm/Lowering-arm.h b/js/src/jit/arm/Lowering-arm.h
@@ -78,7 +78,6 @@ class LIRGeneratorARM : public LIRGeneratorShared {
void lowerWasmBuiltinModI64(MWasmBuiltinModI64* mod);
void lowerUDivI64(MDiv* div);
void lowerUModI64(MMod* mod);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerUDiv(MDiv* div);
void lowerUMod(MMod* mod);
diff --git a/js/src/jit/arm64/Lowering-arm64.cpp b/js/src/jit/arm64/Lowering-arm64.cpp
@@ -240,10 +240,6 @@ void LIRGeneratorARM64::lowerDivI(MDiv* div) {
define(lir, div);
}
-void LIRGeneratorARM64::lowerNegI64(MInstruction* ins, MDefinition* input) {
- defineInt64(new (alloc()) LNegI64(useInt64RegisterAtStart(input)), ins);
-}
-
void LIRGeneratorARM64::lowerMulI(MMul* mul, MDefinition* lhs,
MDefinition* rhs) {
LMulI* lir = new (alloc()) LMulI;
diff --git a/js/src/jit/arm64/Lowering-arm64.h b/js/src/jit/arm64/Lowering-arm64.h
@@ -85,7 +85,6 @@ class LIRGeneratorARM64 : public LIRGeneratorShared {
void lowerWasmBuiltinModI64(MWasmBuiltinModI64* mod);
void lowerUDivI64(MDiv* div);
void lowerUModI64(MMod* mod);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerUDiv(MDiv* div);
void lowerUMod(MMod* mod);
diff --git a/js/src/jit/loong64/Lowering-loong64.cpp b/js/src/jit/loong64/Lowering-loong64.cpp
@@ -150,11 +150,6 @@ void LIRGeneratorLOONG64::defineInt64Phi(MPhi* phi, size_t lirIndex) {
defineTypedPhi(phi, lirIndex);
}
-void LIRGeneratorLOONG64::lowerNegI64(MInstruction* ins, MDefinition* input) {
- defineInt64ReuseInput(new (alloc()) LNegI64(useInt64RegisterAtStart(input)),
- ins, 0);
-}
-
void LIRGeneratorLOONG64::lowerMulI(MMul* mul, MDefinition* lhs,
MDefinition* rhs) {
LMulI* lir = new (alloc()) LMulI;
diff --git a/js/src/jit/loong64/Lowering-loong64.h b/js/src/jit/loong64/Lowering-loong64.h
@@ -62,7 +62,6 @@ class LIRGeneratorLOONG64 : public LIRGeneratorShared {
void lowerInt64PhiInput(MPhi*, uint32_t, LBlock*, size_t);
void defineInt64Phi(MPhi*, size_t);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerDivI(MDiv* div);
void lowerDivI64(MDiv* div);
diff --git a/js/src/jit/mips-shared/Lowering-mips-shared.cpp b/js/src/jit/mips-shared/Lowering-mips-shared.cpp
@@ -172,12 +172,6 @@ void LIRGeneratorMIPSShared::lowerDivI(MDiv* div) {
define(lir, div);
}
-void LIRGeneratorMIPSShared::lowerNegI64(MInstruction* ins,
- MDefinition* input) {
- defineInt64ReuseInput(new (alloc()) LNegI64(useInt64RegisterAtStart(input)),
- ins, 0);
-}
-
void LIRGenerator::visitAbs(MAbs* ins) {
define(allocateAbs(ins, useRegisterAtStart(ins->input())), ins);
}
diff --git a/js/src/jit/mips-shared/Lowering-mips-shared.h b/js/src/jit/mips-shared/Lowering-mips-shared.h
@@ -56,7 +56,6 @@ class LIRGeneratorMIPSShared : public LIRGeneratorShared {
void lowerWasmBuiltinTruncateToInt32(MWasmBuiltinTruncateToInt32* ins);
void lowerDivI(MDiv* div);
void lowerModI(MMod* mod);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerUDiv(MDiv* div);
void lowerUMod(MMod* mod);
diff --git a/js/src/jit/none/Lowering-none.h b/js/src/jit/none/Lowering-none.h
@@ -83,7 +83,6 @@ class LIRGeneratorNone : public LIRGeneratorShared {
void lowerWasmBuiltinDivI64(MWasmBuiltinDivI64* div) { MOZ_CRASH(); }
void lowerModI64(MMod*) { MOZ_CRASH(); }
void lowerWasmBuiltinModI64(MWasmBuiltinModI64* mod) { MOZ_CRASH(); }
- void lowerNegI64(MInstruction*, MDefinition*) { MOZ_CRASH(); }
void lowerMulI(MMul*, MDefinition*, MDefinition*) { MOZ_CRASH(); }
void lowerUDiv(MDiv*) { MOZ_CRASH(); }
void lowerUMod(MMod*) { MOZ_CRASH(); }
diff --git a/js/src/jit/riscv64/Lowering-riscv64.cpp b/js/src/jit/riscv64/Lowering-riscv64.cpp
@@ -150,11 +150,6 @@ void LIRGeneratorRiscv64::defineInt64Phi(MPhi* phi, size_t lirIndex) {
defineTypedPhi(phi, lirIndex);
}
-void LIRGeneratorRiscv64::lowerNegI64(MInstruction* ins, MDefinition* input) {
- defineInt64ReuseInput(new (alloc()) LNegI64(useInt64RegisterAtStart(input)),
- ins, 0);
-}
-
void LIRGeneratorRiscv64::lowerMulI(MMul* mul, MDefinition* lhs,
MDefinition* rhs) {
LMulI* lir = new (alloc()) LMulI;
diff --git a/js/src/jit/riscv64/Lowering-riscv64.h b/js/src/jit/riscv64/Lowering-riscv64.h
@@ -62,7 +62,6 @@ class LIRGeneratorRiscv64 : public LIRGeneratorShared {
void lowerInt64PhiInput(MPhi*, uint32_t, LBlock*, size_t);
void defineInt64Phi(MPhi*, size_t);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerDivI(MDiv* div);
void lowerDivI64(MDiv* div);
diff --git a/js/src/jit/wasm32/Lowering-wasm32.h b/js/src/jit/wasm32/Lowering-wasm32.h
@@ -82,7 +82,6 @@ class LIRGeneratorWasm32 : public LIRGeneratorShared {
void lowerWasmBuiltinDivI64(MWasmBuiltinDivI64* div) { MOZ_CRASH(); }
void lowerModI64(MMod*) { MOZ_CRASH(); }
void lowerWasmBuiltinModI64(MWasmBuiltinModI64* mod) { MOZ_CRASH(); }
- void lowerNegI64(MInstruction*, MDefinition*) { MOZ_CRASH(); }
void lowerMulI(MMul*, MDefinition*, MDefinition*) { MOZ_CRASH(); }
void lowerUDiv(MDiv*) { MOZ_CRASH(); }
void lowerUMod(MMod*) { MOZ_CRASH(); }
diff --git a/js/src/jit/x86-shared/Lowering-x86-shared.cpp b/js/src/jit/x86-shared/Lowering-x86-shared.cpp
@@ -168,11 +168,6 @@ void LIRGeneratorX86Shared::lowerForFPU(LInstructionHelper<1, 2, 0>* ins,
}
}
-void LIRGeneratorX86Shared::lowerNegI64(MInstruction* ins, MDefinition* input) {
- defineInt64ReuseInput(new (alloc()) LNegI64(useInt64RegisterAtStart(input)),
- ins, 0);
-}
-
void LIRGenerator::visitAbs(MAbs* ins) {
defineReuseInput(allocateAbs(ins, useRegisterAtStart(ins->input())), ins, 0);
}
diff --git a/js/src/jit/x86-shared/Lowering-x86-shared.h b/js/src/jit/x86-shared/Lowering-x86-shared.h
@@ -38,7 +38,6 @@ class LIRGeneratorX86Shared : public LIRGeneratorShared {
void lowerForFPU(LInstructionHelper<1, 2, 0>* ins, MDefinition* mir,
MDefinition* lhs, MDefinition* rhs);
- void lowerNegI64(MInstruction* ins, MDefinition* input);
void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
void lowerDivI(MDiv* div);
void lowerModI(MMod* mod);