Bug 945860 - IonMonkey: Fold an unsigned self-mod to zero when there is no divide-by-zero. r=bhackett

This commit is contained in:
Dan Gohman 2013-12-05 08:25:53 -08:00
parent ac608602e0
commit 5272dde5cc
2 changed files with 13 additions and 1 deletions

View File

@ -49,6 +49,18 @@ for (var a = 0; a < 2; ++a) {
bug939893();
}
// bug 945860
function bug945860(x) {
return (x % x);
}
for (var i = 0; i < 2; i++) {
try {
(function() {
assertEq(bug945860(1), 0);
})()
} catch (e) {}
}
// Assorted tests.
function sdiv_truncate(y) {

View File

@ -258,7 +258,7 @@ LIRGeneratorX86Shared::lowerUMod(MMod *mod)
{
// Optimize x%x. The comments in lowerModI apply here as well.
if (mod->lhs() == mod->rhs()) {
if (mod->isTruncated())
if (mod->isTruncated() || (mod->isUnsigned() && !mod->canBeDivideByZero()))
return define(new LInteger(0), mod);
LModSelfI *lir = new LModSelfI(useRegisterAtStart(mod->lhs()));