commit 0b470379848d5f74b6621dd0a2e282fc2bc6b9a6
parent 5806379c0c6697756c4be1fee05c866c2d613c3d
Author: André Bargull <andre.bargull@gmail.com>
Date: Wed, 5 Nov 2025 16:01:28 +0000
Bug 1997975 - Part 6: Remove non-working LModMask for arm64. r=spidermonkey-reviewers,iain
This instruction doesn't actually compare the correct result and it's also no
longer needed after part 5.
Differential Revision: https://phabricator.services.mozilla.com/D271107
Diffstat:
3 files changed, 0 insertions(+), 112 deletions(-)
diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml
@@ -4441,15 +4441,6 @@
denominator: uint32_t
mir_op: Mod
-- name: ModMaskI
- result_type: WordSized
- operands:
- input: WordSized
- arguments:
- shift: int32_t
- num_temps: 2
- mir_op: Mod
-
- name: UDiv
result_type: WordSized
operands:
diff --git a/js/src/jit/arm64/CodeGenerator-arm64.cpp b/js/src/jit/arm64/CodeGenerator-arm64.cpp
@@ -840,100 +840,6 @@ void CodeGenerator::visitUModConstant(LUModConstant* ins) {
}
}
-void CodeGenerator::visitModMaskI(LModMaskI* ins) {
- MMod* mir = ins->mir();
- int32_t shift = ins->shift();
-
- const Register src = ToRegister(ins->input());
- const Register dest = ToRegister(ins->output());
- const Register hold = ToRegister(ins->temp0());
- const Register remain = ToRegister(ins->temp1());
-
- const ARMRegister src32 = ARMRegister(src, 32);
- const ARMRegister dest32 = ARMRegister(dest, 32);
- const ARMRegister remain32 = ARMRegister(remain, 32);
-
- vixl::UseScratchRegisterScope temps(&masm.asVIXL());
- const ARMRegister scratch32 = temps.AcquireW();
- const Register scratch = scratch32.asUnsized();
-
- // We wish to compute x % (1<<y) - 1 for a known constant, y.
- //
- // 1. Let b = (1<<y) and C = (1<<y)-1, then think of the 32 bit dividend as
- // a number in base b, namely c_0*1 + c_1*b + c_2*b^2 ... c_n*b^n
- //
- // 2. Since both addition and multiplication commute with modulus:
- // x % C == (c_0 + c_1*b + ... + c_n*b^n) % C ==
- // (c_0 % C) + (c_1%C) * (b % C) + (c_2 % C) * (b^2 % C)...
- //
- // 3. Since b == C + 1, b % C == 1, and b^n % C == 1 the whole thing
- // simplifies to: c_0 + c_1 + c_2 ... c_n % C
- //
- // Each c_n can easily be computed by a shift/bitextract, and the modulus
- // can be maintained by simply subtracting by C whenever the number gets
- // over C.
- int32_t mask = (1 << shift) - 1;
- Label loop;
-
- // Register 'hold' holds -1 if the value was negative, 1 otherwise.
- // The remain reg holds the remaining bits that have not been processed.
- // The scratch reg serves as a temporary location to store extracted bits.
- // The dest reg is the accumulator, becoming final result.
- //
- // Move the whole value into the remain.
- masm.Mov(remain32, src32);
- // Zero out the dest.
- masm.Mov(dest32, wzr);
- // Set the hold appropriately.
- {
- Label negative;
- masm.branch32(Assembler::Signed, remain, Imm32(0), &negative);
- masm.move32(Imm32(1), hold);
- masm.jump(&loop);
-
- masm.bind(&negative);
- masm.move32(Imm32(-1), hold);
- masm.neg32(remain);
- }
-
- // Begin the main loop.
- masm.bind(&loop);
- {
- // Extract the bottom bits into scratch.
- masm.And(scratch32, remain32, Operand(mask));
- // Add those bits to the accumulator.
- masm.Add(dest32, dest32, scratch32);
- // Do a trial subtraction. This functions as a cmp but remembers the result.
- masm.Subs(scratch32, dest32, Operand(mask));
- // If (sum - C) > 0, store sum - C back into sum, thus performing a modulus.
- {
- Label sumSigned;
- masm.branch32(Assembler::Signed, scratch, scratch, &sumSigned);
- masm.Mov(dest32, scratch32);
- masm.bind(&sumSigned);
- }
- // Get rid of the bits that we extracted before.
- masm.Lsr(remain32, remain32, shift);
- // If the shift produced zero, finish, otherwise, continue in the loop.
- masm.branchTest32(Assembler::NonZero, remain, remain, &loop);
- }
-
- // Check the hold to see if we need to negate the result.
- {
- Label done;
-
- // If the hold was non-zero, negate the result to match JS expectations.
- masm.branchTest32(Assembler::NotSigned, hold, hold, &done);
- if (mir->canBeNegativeDividend() && !mir->isTruncated()) {
- // Bail in case of negative zero hold.
- bailoutTest32(Assembler::Zero, hold, hold, ins->snapshot());
- }
-
- masm.neg32(dest);
- masm.bind(&done);
- }
-}
-
void CodeGeneratorARM64::emitBigIntPtrDiv(LBigIntPtrDiv* ins, Register dividend,
Register divisor, Register output) {
// Callers handle division by zero and integer overflow.
diff --git a/js/src/jit/arm64/Lowering-arm64.cpp b/js/src/jit/arm64/Lowering-arm64.cpp
@@ -278,15 +278,6 @@ void LIRGeneratorARM64::lowerModI(MMod* mod) {
return;
}
- if (shift < 31 && (1 << (shift + 1)) - 1 == rhs) {
- auto* lir = new (alloc()) LModMaskI(lhs, temp(), temp(), shift + 1);
- if (mod->fallible()) {
- assignSnapshot(lir, mod->bailoutKind());
- }
- define(lir, mod);
- return;
- }
-
auto* lir = new (alloc()) LModConstantI(lhs, rhs);
if (mod->fallible()) {
assignSnapshot(lir, mod->bailoutKind());