Bug 1049691 - Fold Loads to their store value when possible. r=sunfish

This commit is contained in:
Nicolas B. Pierron 2014-08-07 02:30:39 -07:00
parent 400f767c33
commit fd330d9393
2 changed files with 89 additions and 0 deletions

View File

@ -2971,6 +2971,28 @@ MLoadFixedSlot::mightAlias(const MDefinition *store) const
return true;
}
MDefinition *
MLoadFixedSlot::foldsTo(TempAllocator &alloc)
{
if (!dependency() || !dependency()->isStoreFixedSlot())
return this;
MStoreFixedSlot *store = dependency()->toStoreFixedSlot();
if (!store->block()->dominates(block()))
return this;
if (store->object() != object())
return this;
if (store->slot() != slot())
return this;
if (store->value()->type() != type())
return this;
return store->value();
}
bool
MAsmJSLoadHeap::mightAlias(const MDefinition *def) const
{
@ -3023,6 +3045,25 @@ MAsmJSLoadGlobalVar::congruentTo(const MDefinition *ins) const
return false;
}
MDefinition *
MAsmJSLoadGlobalVar::foldsTo(TempAllocator &alloc)
{
if (!dependency() || !dependency()->isAsmJSStoreGlobalVar())
return this;
MAsmJSStoreGlobalVar *store = dependency()->toAsmJSStoreGlobalVar();
if (!store->block()->dominates(block()))
return this;
if (store->globalDataOffset() != globalDataOffset())
return this;
if (store->value()->type() != type())
return this;
return store->value();
}
HashNumber
MAsmJSLoadFuncPtr::valueHash() const
{
@ -3075,6 +3116,47 @@ MLoadSlot::valueHash() const
return hash;
}
MDefinition *
MLoadSlot::foldsTo(TempAllocator &alloc)
{
if (!dependency() || !dependency()->isStoreSlot())
return this;
MStoreSlot *store = dependency()->toStoreSlot();
if (!store->block()->dominates(block()))
return this;
if (store->slots() != slots())
return this;
if (store->value()->type() != type())
return this;
return store->value();
}
MDefinition *
MLoadElement::foldsTo(TempAllocator &alloc)
{
if (!dependency() || !dependency()->isStoreElement())
return this;
MStoreElement *store = dependency()->toStoreElement();
if (!store->block()->dominates(block()))
return this;
if (store->elements() != elements())
return this;
if (store->index() != index())
return this;
if (store->value()->type() != type())
return this;
return store->value();
}
bool
MGuardShapePolymorphic::congruentTo(const MDefinition *ins) const
{

View File

@ -6625,6 +6625,7 @@ class MLoadElement
return false;
return congruentIfOperandsEqual(other);
}
MDefinition *foldsTo(TempAllocator &alloc);
AliasSet getAliasSet() const {
return AliasSet::Load(AliasSet::Element);
}
@ -7423,6 +7424,8 @@ class MLoadFixedSlot
return congruentIfOperandsEqual(ins);
}
MDefinition *foldsTo(TempAllocator &alloc);
AliasSet getAliasSet() const {
return AliasSet::Load(AliasSet::FixedSlot);
}
@ -8314,6 +8317,9 @@ class MLoadSlot
return false;
return congruentIfOperandsEqual(ins);
}
MDefinition *foldsTo(TempAllocator &alloc);
AliasSet getAliasSet() const {
JS_ASSERT(slots()->type() == MIRType_Slots);
return AliasSet::Load(AliasSet::DynamicSlot);
@ -10591,6 +10597,7 @@ class MAsmJSLoadGlobalVar : public MNullaryInstruction
HashNumber valueHash() const;
bool congruentTo(const MDefinition *ins) const;
MDefinition *foldsTo(TempAllocator &alloc);
AliasSet getAliasSet() const {
return isConstant_ ? AliasSet::None() : AliasSet::Load(AliasSet::AsmJSGlobalVar);