Skip to content

Commit

Permalink
Bug 1298747 - IonMonkey: MIPS: Uses conditional move in MacroAssemble…
Browse files Browse the repository at this point in the history
…r::clampIntToUint8. r=arai

---
 js/src/jit/mips32/MacroAssembler-mips32.cpp | 28 ++++++++--------------------
 js/src/jit/mips64/MacroAssembler-mips64.cpp | 28 ++++++++--------------------
 2 files changed, 16 insertions(+), 40 deletions(-)
  • Loading branch information
heiher committed Aug 29, 2016
1 parent 0d349d1 commit 2415f07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
28 changes: 8 additions & 20 deletions js/src/jit/mips32/MacroAssembler-mips32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,26 +1067,14 @@ MacroAssemblerMIPSCompat::storePtr(Register src, AbsoluteAddress dest)
void
MacroAssemblerMIPSCompat::clampIntToUint8(Register reg)
{
// look at (reg >> 8) if it is 0, then src shouldn't be clamped
// if it is <0, then we want to clamp to 0,
// otherwise, we wish to clamp to 255
Label done;
ma_move(ScratchRegister, reg);
asMasm().rshiftPtrArithmetic(Imm32(8), ScratchRegister);
ma_b(ScratchRegister, ScratchRegister, &done, Assembler::Zero, ShortJump);
{
Label negative;
ma_b(ScratchRegister, ScratchRegister, &negative, Assembler::Signed, ShortJump);
{
ma_li(reg, Imm32(255));
ma_b(&done, ShortJump);
}
bind(&negative);
{
ma_move(reg, zero);
}
}
bind(&done);
// If reg is < 0, then we want to clamp to 0.
as_slti(ScratchRegister, reg, 0);
as_movn(reg, zero, ScratchRegister);

// If reg is >= 255, then we want to clamp to 255.
ma_li(SecondScratchReg, Imm32(255));
as_slti(ScratchRegister, reg, 255);
as_movz(reg, SecondScratchReg, ScratchRegister);
}

// Note: this function clobbers the input register.
Expand Down
28 changes: 8 additions & 20 deletions js/src/jit/mips64/MacroAssembler-mips64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,26 +1214,14 @@ MacroAssemblerMIPS64Compat::storePtr(Register src, AbsoluteAddress dest)
void
MacroAssemblerMIPS64Compat::clampIntToUint8(Register reg)
{
// look at (reg >> 8) if it is 0, then src shouldn't be clamped
// if it is <0, then we want to clamp to 0,
// otherwise, we wish to clamp to 255
Label done;
ma_move(ScratchRegister, reg);
asMasm().rshiftPtrArithmetic(Imm32(8), ScratchRegister);
ma_b(ScratchRegister, ScratchRegister, &done, Assembler::Zero, ShortJump);
{
Label negative;
ma_b(ScratchRegister, ScratchRegister, &negative, Assembler::Signed, ShortJump);
{
ma_li(reg, Imm32(255));
ma_b(&done, ShortJump);
}
bind(&negative);
{
ma_move(reg, zero);
}
}
bind(&done);
// If reg is < 0, then we want to clamp to 0.
as_slti(ScratchRegister, reg, 0);
as_movn(reg, zero, ScratchRegister);

// If reg is >= 255, then we want to clamp to 255.
ma_li(SecondScratchReg, Imm32(255));
as_slti(ScratchRegister, reg, 255);
as_movz(reg, SecondScratchReg, ScratchRegister);
}

// Note: this function clobbers the input register.
Expand Down

0 comments on commit 2415f07

Please sign in to comment.