Bug 1293542 - IonMonkey: Fix the logic of pow, r=sunfish

This commit is contained in:
Hannes Verschore 2016-08-30 10:57:06 +02:00
parent 114e53ff4e
commit e6d8c010cd
2 changed files with 13 additions and 5 deletions

View File

@ -0,0 +1,7 @@
function f(x) {
return (x ** (1 / ~4294967297)) && x;
};
for (var i = 0; i < 2; ++i) {
assertEq(f(-Infinity), 0);
}

View File

@ -878,8 +878,8 @@ CodeGeneratorX86Shared::visitPowHalfD(LPowHalfD* ins)
masm.branchDouble(cond, input, scratch, &sqrt);
// Math.pow(-Infinity, 0.5) == Infinity.
masm.zeroDouble(input);
masm.subDouble(scratch, input);
masm.zeroDouble(output);
masm.subDouble(scratch, output);
masm.jump(&done);
masm.bind(&sqrt);
@ -888,11 +888,12 @@ CodeGeneratorX86Shared::visitPowHalfD(LPowHalfD* ins)
if (!ins->mir()->operandIsNeverNegativeZero()) {
// Math.pow(-0, 0.5) == 0 == Math.pow(0, 0.5). Adding 0 converts any -0 to 0.
masm.zeroDouble(scratch);
masm.addDouble(scratch, input);
masm.addDouble(input, scratch);
masm.vsqrtsd(scratch, output, output);
} else {
masm.vsqrtsd(input, output, output);
}
masm.vsqrtsd(input, output, output);
masm.bind(&done);
}