commit 8d47d89b0dba53b0104e5aee0baf6a890ef07706
parent 253f810be52f48f616e70d7963685fb6b6359651
Author: André Bargull <andre.bargull@gmail.com>
Date: Fri, 24 Oct 2025 14:58:56 +0000
Bug 1996088: Remove unused temp registers from 64-bit div/mod LIR instructions. r=spidermonkey-reviewers,jandem
Differential Revision: https://phabricator.services.mozilla.com/D269845
Diffstat:
6 files changed, 39 insertions(+), 57 deletions(-)
diff --git a/js/src/jit/loong64/LIR-loong64.h b/js/src/jit/loong64/LIR-loong64.h
@@ -60,19 +60,16 @@ class LUDivOrMod : public LBinaryMath<0> {
}
};
-class LDivOrModI64 : public LBinaryMath<1> {
+class LDivOrModI64 : public LBinaryMath<0> {
public:
- LIR_HEADER(DivOrModI64)
+ LIR_HEADER(DivOrModI64);
- LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
MBinaryArithInstruction* mir() const {
MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
return static_cast<MBinaryArithInstruction*>(mir_);
@@ -99,19 +96,16 @@ class LDivOrModI64 : public LBinaryMath<1> {
}
};
-class LUDivOrModI64 : public LBinaryMath<1> {
+class LUDivOrModI64 : public LBinaryMath<0> {
public:
LIR_HEADER(UDivOrModI64);
- LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
const char* extraName() const {
return mir()->isTruncated() ? "Truncated" : nullptr;
}
diff --git a/js/src/jit/loong64/Lowering-loong64.cpp b/js/src/jit/loong64/Lowering-loong64.cpp
@@ -210,8 +210,8 @@ void LIRGeneratorLOONG64::lowerDivI64(MDiv* div) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc())
+ LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()));
defineInt64(lir, div);
}
@@ -257,8 +257,8 @@ void LIRGeneratorLOONG64::lowerModI64(MMod* mod) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc())
+ LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()));
defineInt64(lir, mod);
}
@@ -277,8 +277,8 @@ void LIRGeneratorLOONG64::lowerUDiv(MDiv* div) {
}
void LIRGeneratorLOONG64::lowerUDivI64(MDiv* div) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc())
+ LUDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()));
defineInt64(lir, div);
}
@@ -297,8 +297,8 @@ void LIRGeneratorLOONG64::lowerUMod(MMod* mod) {
}
void LIRGeneratorLOONG64::lowerUModI64(MMod* mod) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc())
+ LUDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()));
defineInt64(lir, mod);
}
diff --git a/js/src/jit/mips64/LIR-mips64.h b/js/src/jit/mips64/LIR-mips64.h
@@ -26,19 +26,16 @@ class LUnbox : public LInstructionHelper<1, BOX_PIECES, 0> {
const char* extraName() const { return StringFromMIRType(mir()->type()); }
};
-class LDivOrModI64 : public LBinaryMath<1> {
+class LDivOrModI64 : public LBinaryMath<0> {
public:
- LIR_HEADER(DivOrModI64)
+ LIR_HEADER(DivOrModI64);
- LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
MBinaryArithInstruction* mir() const {
MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
return static_cast<MBinaryArithInstruction*>(mir_);
@@ -65,19 +62,16 @@ class LDivOrModI64 : public LBinaryMath<1> {
}
};
-class LUDivOrModI64 : public LBinaryMath<1> {
+class LUDivOrModI64 : public LBinaryMath<0> {
public:
LIR_HEADER(UDivOrModI64);
- LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
const char* extraName() const {
return mir()->isTruncated() ? "Truncated" : nullptr;
}
diff --git a/js/src/jit/mips64/Lowering-mips64.cpp b/js/src/jit/mips64/Lowering-mips64.cpp
@@ -41,8 +41,8 @@ void LIRGeneratorMIPS64::lowerDivI64(MDiv* div) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc())
+ LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()));
defineInt64(lir, div);
}
@@ -56,8 +56,8 @@ void LIRGeneratorMIPS64::lowerModI64(MMod* mod) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc())
+ LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()));
defineInt64(lir, mod);
}
@@ -66,14 +66,14 @@ void LIRGeneratorMIPS64::lowerWasmBuiltinModI64(MWasmBuiltinModI64* mod) {
}
void LIRGeneratorMIPS64::lowerUDivI64(MDiv* div) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc())
+ LUDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()));
defineInt64(lir, div);
}
void LIRGeneratorMIPS64::lowerUModI64(MMod* mod) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc())
+ LUDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()));
defineInt64(lir, mod);
}
diff --git a/js/src/jit/riscv64/LIR-riscv64.h b/js/src/jit/riscv64/LIR-riscv64.h
@@ -60,19 +60,16 @@ class LUDivOrMod : public LBinaryMath<0> {
}
};
-class LDivOrModI64 : public LBinaryMath<1> {
+class LDivOrModI64 : public LBinaryMath<0> {
public:
- LIR_HEADER(DivOrModI64)
+ LIR_HEADER(DivOrModI64);
- LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
MBinaryArithInstruction* mir() const {
MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
return static_cast<MBinaryArithInstruction*>(mir_);
@@ -99,19 +96,16 @@ class LDivOrModI64 : public LBinaryMath<1> {
}
};
-class LUDivOrModI64 : public LBinaryMath<1> {
+class LUDivOrModI64 : public LBinaryMath<0> {
public:
LIR_HEADER(UDivOrModI64);
- LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
- const LDefinition& temp)
+ LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
: LBinaryMath(classOpcode) {
setOperand(0, lhs);
setOperand(1, rhs);
- setTemp(0, temp);
}
- const LDefinition* remainder() { return getTemp(0); }
const char* extraName() const {
return mir()->isTruncated() ? "Truncated" : nullptr;
}
diff --git a/js/src/jit/riscv64/Lowering-riscv64.cpp b/js/src/jit/riscv64/Lowering-riscv64.cpp
@@ -210,8 +210,8 @@ void LIRGeneratorRiscv64::lowerDivI64(MDiv* div) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc()) LDivOrModI64(useRegisterAtStart(div->lhs()),
+ useRegisterAtStart(div->rhs()));
defineInt64(lir, div);
}
@@ -257,8 +257,8 @@ void LIRGeneratorRiscv64::lowerModI64(MMod* mod) {
return;
}
- LDivOrModI64* lir = new (alloc())
- LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc()) LDivOrModI64(useRegisterAtStart(mod->lhs()),
+ useRegisterAtStart(mod->rhs()));
defineInt64(lir, mod);
}
@@ -277,8 +277,8 @@ void LIRGeneratorRiscv64::lowerUDiv(MDiv* div) {
}
void LIRGeneratorRiscv64::lowerUDivI64(MDiv* div) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()), temp());
+ auto* lir = new (alloc()) LUDivOrModI64(useRegisterAtStart(div->lhs()),
+ useRegisterAtStart(div->rhs()));
defineInt64(lir, div);
}
@@ -297,8 +297,8 @@ void LIRGeneratorRiscv64::lowerUMod(MMod* mod) {
}
void LIRGeneratorRiscv64::lowerUModI64(MMod* mod) {
- LUDivOrModI64* lir = new (alloc())
- LUDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
+ auto* lir = new (alloc()) LUDivOrModI64(useRegisterAtStart(mod->lhs()),
+ useRegisterAtStart(mod->rhs()));
defineInt64(lir, mod);
}