Bug 848803: LICM shouldn't hoist intructions that depend on instruction in or after the loop, r=jandem

This commit is contained in:
Hannes Verschore 2013-03-12 18:37:15 +01:00
parent 5be57034d5
commit c53cfadb7f
3 changed files with 47 additions and 3 deletions

View File

@ -199,6 +199,12 @@ Loop::isInLoop(MDefinition *ins)
return ins->block()->isMarked();
}
bool
Loop::isBeforeLoop(MDefinition *ins)
{
return ins->block()->id() < header_->id();
}
bool
Loop::isLoopInvariant(MInstruction *ins)
{
@ -208,10 +214,13 @@ Loop::isLoopInvariant(MInstruction *ins)
return false;
}
// Don't hoist if this instruction depends on a store inside the loop.
if (ins->dependency() && isInLoop(ins->dependency())) {
// Don't hoist if this instruction depends on a store inside or after the loop.
// Note: "after the loop" can sound strange, but Alias Analysis doesn't look
// at the control flow. Therefore it doesn't match the definition here, that a block
// is in the loop when there is a (directed) path from the block to the loop header.
if (ins->dependency() && !isBeforeLoop(ins->dependency())) {
if (IonSpewEnabled(IonSpew_LICM)) {
fprintf(IonSpewFile, "depends on store inside loop: ");
fprintf(IonSpewFile, "depends on store inside or after loop: ");
ins->dependency()->printName(IonSpewFile);
fprintf(IonSpewFile, "\n");
}

View File

@ -74,6 +74,7 @@ class Loop
// Utility methods for invariance testing and instruction hoisting.
bool isInLoop(MDefinition *ins);
bool isBeforeLoop(MDefinition *ins);
bool isLoopInvariant(MInstruction *ins);
bool isLoopInvariant(MDefinition *ins);

View File

@ -0,0 +1,34 @@
var JSIL = {};
JSIL.TypeNameParseState = function ()
{
this.input = 15;
this.pos = 0
};
JSIL.TypeNameParseState.prototype.substr = function (e)
{
return e;
};
JSIL.TypeNameParseState.prototype.moveNext = function ()
{
this.pos += 1;
return this.pos < this.input;
};
JSIL.TypeNameParseResult = function () {};
JSIL.ParseTypeNameImpl = function (n)
{
var i = new JSIL.TypeNameParseState()
var u = new JSIL.TypeNameParseResult;
while (i.moveNext())
{
if (n)
{
while (true)
u.assembly = 1
}
u.assembly = i.substr(i.pos + 1);
}
return u
};
var u = JSIL.ParseTypeNameImpl(false)
assertEq(u.assembly, 15)