Bug 1024515 - IonMonkey MIPS: Don't use ScratchRegister in ModMaskI. r=mjrosenb

This commit is contained in:
Branislav Rankov 2014-06-26 13:45:54 +02:00
Родитель 70a973a8ca
Коммит c565bd8a1f
5 изменённых файлов: 30 добавлений и 27 удалений

Просмотреть файл

@ -793,18 +793,19 @@ CodeGeneratorMIPS::visitModMaskI(LModMaskI *ins)
{
Register src = ToRegister(ins->getOperand(0));
Register dest = ToRegister(ins->getDef(0));
Register tmp = ToRegister(ins->getTemp(0));
Register tmp0 = ToRegister(ins->getTemp(0));
Register tmp1 = ToRegister(ins->getTemp(1));
MMod *mir = ins->mir();
if (!mir->isTruncated() && mir->canBeNegativeDividend()) {
MOZ_ASSERT(mir->fallible());
Label bail;
masm.ma_mod_mask(src, dest, tmp, ins->shift(), &bail);
masm.ma_mod_mask(src, dest, tmp0, tmp1, ins->shift(), &bail);
if (!bailoutFrom(&bail, ins->snapshot()))
return false;
} else {
masm.ma_mod_mask(src, dest, tmp, ins->shift(), nullptr);
masm.ma_mod_mask(src, dest, tmp0, tmp1, ins->shift(), nullptr);
}
return true;
}

Просмотреть файл

@ -208,18 +208,20 @@ class LModPowTwoI : public LInstructionHelper<1, 1, 0>
}
};
class LModMaskI : public LInstructionHelper<1, 1, 1>
class LModMaskI : public LInstructionHelper<1, 1, 2>
{
const int32_t shift_;
public:
LIR_HEADER(ModMaskI);
LModMaskI(const LAllocation &lhs, const LDefinition &temp1, int32_t shift)
LModMaskI(const LAllocation &lhs, const LDefinition &temp0, const LDefinition &temp1,
int32_t shift)
: shift_(shift)
{
setOperand(0, lhs);
setTemp(0, temp1);
setTemp(0, temp0);
setTemp(1, temp1);
}
int32_t shift() const {

Просмотреть файл

@ -322,7 +322,9 @@ LIRGeneratorMIPS::lowerModI(MMod *mod)
return define(lir, mod);
} else if (shift < 31 && (1 << (shift + 1)) - 1 == rhs) {
LModMaskI *lir = new(alloc()) LModMaskI(useRegister(mod->lhs()),
temp(LDefinition::GENERAL), shift + 1);
temp(LDefinition::GENERAL),
temp(LDefinition::GENERAL),
shift + 1);
if (mod->fallible() && !assignSnapshot(lir, Bailout_DoubleOutput))
return false;
return define(lir, mod);

Просмотреть файл

@ -620,8 +620,8 @@ MacroAssemblerMIPS::ma_div_branch_overflow(Register rd, Register rs, Imm32 imm,
}
void
MacroAssemblerMIPS::ma_mod_mask(Register src, Register dest, Register hold, int32_t shift,
Label *negZero)
MacroAssemblerMIPS::ma_mod_mask(Register src, Register dest, Register hold, Register remain,
int32_t shift, Label *negZero)
{
// MATH:
// We wish to compute x % (1<<y) - 1 for a known constant, y.
@ -641,34 +641,32 @@ MacroAssemblerMIPS::ma_mod_mask(Register src, Register dest, Register hold, int3
Label head, negative, sumSigned, done;
// hold holds -1 if the value was negative, 1 otherwise.
// ScratchRegister holds the remaining bits that have not been processed
// lr serves as a temporary location to store extracted bits into as well
// as holding the trial subtraction as a temp value dest is the
// accumulator (and holds the final result)
// remain holds the remaining bits that have not been processed
// SecondScratchReg serves as a temporary location to store extracted bits
// into as well as holding the trial subtraction as a temp value dest is
// the accumulator (and holds the final result)
// move the whole value into the scratch register, setting the codition
// codes so we can muck with them later.
ma_move(ScratchRegister, src);
// move the whole value into the remain.
ma_move(remain, src);
// Zero out the dest.
ma_subu(dest, dest, dest);
ma_li(dest, Imm32(0));
// Set the hold appropriately.
ma_b(ScratchRegister, ScratchRegister, &negative, Signed, ShortJump);
ma_b(remain, remain, &negative, Signed, ShortJump);
ma_li(hold, Imm32(1));
ma_b(&head, ShortJump);
bind(&negative);
ma_li(hold, Imm32(-1));
ma_negu(ScratchRegister, ScratchRegister);
ma_negu(remain, remain);
// Begin the main loop.
bind(&head);
// Extract the bottom bits into lr.
ma_and(SecondScratchReg, ScratchRegister, Imm32(mask));
// Extract the bottom bits into SecondScratchReg.
ma_and(SecondScratchReg, remain, Imm32(mask));
// Add those bits to the accumulator.
as_addu(dest, dest, SecondScratchReg);
// Do a trial subtraction, this is the same operation as cmp, but we
// store the dest
// Do a trial subtraction
ma_subu(SecondScratchReg, dest, Imm32(mask));
// If (sum - C) > 0, store sum - C back into sum, thus performing a
// modulus.
@ -676,9 +674,9 @@ MacroAssemblerMIPS::ma_mod_mask(Register src, Register dest, Register hold, int3
ma_move(dest, SecondScratchReg);
bind(&sumSigned);
// Get rid of the bits that we extracted before.
as_srl(ScratchRegister, ScratchRegister, shift);
as_srl(remain, remain, shift);
// If the shift produced zero, finish, otherwise, continue in the loop.
ma_b(ScratchRegister, ScratchRegister, &head, NonZero, ShortJump);
ma_b(remain, remain, &head, NonZero, ShortJump);
// Check the hold to see if we need to negate the result.
ma_b(hold, hold, &done, NotSigned, ShortJump);

Просмотреть файл

@ -200,8 +200,8 @@ class MacroAssemblerMIPS : public Assembler
// fast mod, uses scratch registers, and thus needs to be in the assembler
// implicitly assumes that we can overwrite dest at the beginning of the sequence
void ma_mod_mask(Register src, Register dest, Register hold, int32_t shift,
Label *negZero = nullptr);
void ma_mod_mask(Register src, Register dest, Register hold, Register remain,
int32_t shift, Label *negZero = nullptr);
// memory
// shortcut for when we know we're transferring 32 bits of data