Bug 1940716 - convertDoubleToInt32: Clobber destination register when zero. a=dmeehan

Original Revision: https://phabricator.services.mozilla.com/D234893

Differential Revision: https://phabricator.services.mozilla.com/D236700
This commit is contained in:
Nicolas B. Pierron 2025-02-07 14:16:53 +00:00
parent 9ca513777a
commit c3b0d15ca3
2 changed files with 26 additions and 9 deletions

View file

@ -139,13 +139,17 @@ void MacroAssemblerARM::convertDoubleToInt32(FloatRegister src, Register dest,
ma_b(fail, Assembler::VFP_NotEqualOrUnordered);
if (negativeZeroCheck) {
Label nonzero;
as_cmp(dest, Imm8(0));
ma_b(&nonzero, Assembler::NotEqual);
// Test and bail for -0.0, when integer result is 0. Move the top word
// of the double into the output reg, if it is non-zero, then the
// original value was -0.0.
as_vxfer(dest, InvalidReg, src, FloatToCore, Assembler::Equal, 1);
ma_cmp(dest, Imm32(0x80000000), scratch, Assembler::Equal);
ma_b(fail, Assembler::Equal);
as_vxfer(dest, InvalidReg, src, FloatToCore, Assembler::Always, 1);
as_cmp(dest, Imm8(0));
ma_b(fail, Assembler::LessThan);
ma_mov(Imm32(0), dest);
bind(&nonzero);
}
}
@ -180,14 +184,18 @@ void MacroAssemblerARM::convertFloat32ToInt32(FloatRegister src, Register dest,
ma_b(fail, Assembler::Equal);
if (negativeZeroCheck) {
Label nonzero;
as_cmp(dest, Imm8(0));
ma_b(&nonzero, Assembler::NotEqual);
// Test and bail for -0.0, when integer result is 0. Move the float into
// the output reg, and if it is non-zero then the original value was
// -0.0
as_vxfer(dest, InvalidReg, VFPRegister(src).singleOverlay(), FloatToCore,
Assembler::Equal, 0);
ma_cmp(dest, Imm32(0x80000000), scratch, Assembler::Equal);
ma_b(fail, Assembler::Equal);
Assembler::Always, 0);
as_cmp(dest, Imm8(0));
ma_b(fail, Assembler::LessThan);
ma_mov(Imm32(0), dest);
bind(&nonzero);
}
}

View file

@ -626,8 +626,11 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
if (negativeZeroCheck) {
Label nonzero;
Cbnz(dest32, &nonzero);
// dest32 is 0, fail if fsrc64 is negative.
Fmov(dest64, fsrc64);
Cbnz(dest64, fail);
Cmp(dest64, xzr);
B(fail, Assembler::Signed);
Mov(dest64, xzr);
bind(&nonzero);
}
}
@ -651,8 +654,11 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
if (negativeZeroCheck) {
Label nonzero;
Cbnz(dest32, &nonzero);
// dest32 is 0, fail if fsrc64 is negative.
Fmov(dest32, fsrc);
Cbnz(dest32, fail);
Cmp(dest32, xzr);
B(fail, Assembler::Signed);
Mov(dest32, xzr);
bind(&nonzero);
}
Uxtw(dest64, dest64);
@ -678,8 +684,11 @@ class MacroAssemblerCompat : public vixl::MacroAssembler {
if (negativeZeroCheck) {
Label nonzero;
Cbnz(dest64, &nonzero);
// dest64 is 0, fail if fsrc64 is negative.
Fmov(dest64, fsrc64);
Cbnz(dest64, fail);
Cmp(dest64, xzr);
B(fail, Assembler::Signed);
Mov(dest64, xzr);
bind(&nonzero);
}
}