Bug 876607 - IonMonkey: Reordering of operands should look to real use count, r=sstangl

This commit is contained in:
Hannes Verschore 2013-06-06 15:35:13 +02:00
Родитель 4b0528c455
Коммит 3fcf048742
3 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -858,7 +858,13 @@ ReorderCommutative(MDefinition **lhsp, MDefinition **rhsp)
// Ensure that if there is a constant, then it is in rhs.
// In addition, since clobbering binary operations clobber the left
// operand, prefer a non-constant lhs operand with no further uses.
if (lhs->isConstant() || (!rhs->isConstant() && rhs->useCount() == 1)) {
if (rhs->isConstant())
return;
if (lhs->isConstant() ||
(lhs->defUseCount() == 1 && rhs->defUseCount() != 1))
{
*rhsp = lhs;
*lhsp = rhs;
}

Просмотреть файл

@ -241,6 +241,16 @@ MDefinition::useCount() const
return count;
}
size_t
MDefinition::defUseCount() const
{
size_t count = 0;
for (MUseIterator i(uses_.begin()); i != uses_.end(); i++)
if ((*i)->consumer()->isDefinition())
count++;
return count;
}
MUseIterator
MDefinition::removeUse(MUseIterator use)
{

Просмотреть файл

@ -441,6 +441,10 @@ class MDefinition : public MNode
// Number of uses of this instruction.
size_t useCount() const;
// Number of uses of this instruction.
// (only counting MDefinitions, ignoring MResumePoints)
size_t defUseCount() const;
bool hasUses() const {
return !uses_.empty();
}