Bug 1159899: IonMonkey: Fix folding of ~~x, r=nbp

This commit is contained in:
Hannes Verschore 2015-05-07 02:58:27 +02:00
parent 347be52cbf
commit 55c7b88f84
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,5 @@
function f(x) {
return ~~(x >>> 0) / (x >>> 0) | 0
}
f(1)
assertEq(f(-1), 0);

View File

@ -2977,7 +2977,7 @@ MBitNot::foldsTo(TempAllocator& alloc)
if (input->isBitNot() && input->toBitNot()->specialization_ == MIRType_Int32) {
MOZ_ASSERT(input->toBitNot()->getOperand(0)->type() == MIRType_Int32);
return input->toBitNot()->getOperand(0); // ~~x => x
return MTruncateToInt32::New(alloc, input->toBitNot()->input()); // ~~x => x | 0
}
return this;