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 src = ToRegister(ins->getOperand(0));
Register dest = ToRegister(ins->getDef(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(); MMod *mir = ins->mir();
if (!mir->isTruncated() && mir->canBeNegativeDividend()) { if (!mir->isTruncated() && mir->canBeNegativeDividend()) {
MOZ_ASSERT(mir->fallible()); MOZ_ASSERT(mir->fallible());
Label bail; 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())) if (!bailoutFrom(&bail, ins->snapshot()))
return false; return false;
} else { } else {
masm.ma_mod_mask(src, dest, tmp, ins->shift(), nullptr); masm.ma_mod_mask(src, dest, tmp0, tmp1, ins->shift(), nullptr);
} }
return true; 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_; const int32_t shift_;
public: public:
LIR_HEADER(ModMaskI); 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) : shift_(shift)
{ {
setOperand(0, lhs); setOperand(0, lhs);
setTemp(0, temp1); setTemp(0, temp0);
setTemp(1, temp1);
} }
int32_t shift() const { int32_t shift() const {

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

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

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

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