Example #1
0
MControlInstruction *
ValueNumberer::simplifyControlInstruction(MControlInstruction *def)
{
    if (def->isEffectful())
        return def;

    MDefinition *repl = def->foldsTo(alloc(), false);
    if (repl == def)
        return def;

    // Ensure this instruction has a value number.
    if (!repl->valueNumberData())
        repl->setValueNumberData(new(alloc()) ValueNumberData);

    MBasicBlock *block = def->block();

    // MControlInstructions should not have consumers.
    JS_ASSERT(repl->isControlInstruction());
    JS_ASSERT(!def->hasUses());

    if (def->isInWorklist())
        repl->setInWorklist();

    block->discardLastIns();
    block->end(repl->toControlInstruction());
    return repl->toControlInstruction();
}