Bug 1154971 - ValueNumbering: Skip finding the leader if the simplified instruction existed before the simplification. r=sunfish

This commit is contained in:
Nicolas B. Pierron 2015-05-12 11:26:52 +02:00
parent f87f1b54e6
commit f94c5331d1
3 changed files with 20 additions and 5 deletions

View File

@ -0,0 +1,10 @@
function f(x, y) {
return Math.imul(0, Math.imul(y | 0, x >> 0))
}
for (var i = 0; i < 2; i++) {
try {
(f(1 ? 0 : undefined))()
} catch (e) {}
}

View File

@ -287,7 +287,6 @@ MInstruction::foldsToStoredValue(TempAllocator& alloc, MDefinition* loaded)
MOZ_ASSERT(loaded->type() < MIRType_Value);
MBox* box = MBox::New(alloc, loaded);
block()->insertBefore(this, box);
loaded = box;
}
@ -2316,7 +2315,6 @@ MMinMax::foldsTo(TempAllocator& alloc)
MLimitedTruncate::New(alloc, operand->getOperand(0), MDefinition::NoTruncate);
block()->insertBefore(this, limit);
MToDouble* toDouble = MToDouble::New(alloc, limit);
block()->insertBefore(this, toDouble);
return toDouble;
}
@ -2326,7 +2324,6 @@ MMinMax::foldsTo(TempAllocator& alloc)
MLimitedTruncate::New(alloc, operand->getOperand(0), MDefinition::NoTruncate);
block()->insertBefore(this, limit);
MToDouble* toDouble = MToDouble::New(alloc, limit);
block()->insertBefore(this, toDouble);
return toDouble;
}
}
@ -4669,7 +4666,8 @@ MTableSwitch::foldsTo(TempAllocator& alloc)
}
MDefinition*
MArrayJoin::foldsTo(TempAllocator& alloc) {
MArrayJoin::foldsTo(TempAllocator& alloc)
{
// :TODO: Enable this optimization after fixing Bug 977966 test cases.
return this;

View File

@ -756,8 +756,10 @@ ValueNumberer::visitDefinition(MDefinition* def)
if (sim == nullptr)
return false;
bool isNewInstruction = sim->block() == nullptr;
// If |sim| doesn't belong to a block, insert it next to |def|.
if (sim->block() == nullptr)
if (isNewInstruction)
def->block()->insertAfter(def->toInstruction(), sim->toInstruction());
#ifdef DEBUG
@ -783,6 +785,11 @@ ValueNumberer::visitDefinition(MDefinition* def)
// Otherwise, procede to optimize with |sim| in place of |def|.
def = sim;
// If the simplified instruction was already part of the graph, then we
// probably already visited and optimized this instruction.
if (!isNewInstruction)
return true;
}
// Now that foldsTo is done, re-enable the original dependency. Even though