mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1019188 - Transform phi(int32,boolean) into phi(int32,int32) when it is only consumed by test instructions, r=sunfish.
This commit is contained in:
parent
cbf53ad0d6
commit
7d96533635
@ -2446,6 +2446,42 @@ MCompare::operandTruncateKind(size_t index) const
|
||||
return truncateOperands_ ? TruncateAfterBailouts : NoTruncate;
|
||||
}
|
||||
|
||||
static void
|
||||
TruncateTest(TempAllocator &alloc, MTest *test)
|
||||
{
|
||||
// If all possible inputs to the test are either int32 or boolean,
|
||||
// convert those inputs to int32 so that an int32 test can be performed.
|
||||
|
||||
if (test->input()->type() != MIRType_Value)
|
||||
return;
|
||||
|
||||
if (!test->input()->isPhi() || !test->input()->hasOneDefUse() || test->input()->isImplicitlyUsed())
|
||||
return;
|
||||
|
||||
MPhi *phi = test->input()->toPhi();
|
||||
for (size_t i = 0; i < phi->numOperands(); i++) {
|
||||
MDefinition *def = phi->getOperand(i);
|
||||
if (!def->isBox())
|
||||
return;
|
||||
MDefinition *inner = def->getOperand(0);
|
||||
if (inner->type() != MIRType_Boolean && inner->type() != MIRType_Int32)
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < phi->numOperands(); i++) {
|
||||
MDefinition *inner = phi->getOperand(i)->getOperand(0);
|
||||
if (inner->type() != MIRType_Int32) {
|
||||
MBasicBlock *block = inner->block();
|
||||
inner = MToInt32::New(alloc, inner);
|
||||
block->insertBefore(block->lastIns(), inner->toInstruction());
|
||||
}
|
||||
JS_ASSERT(inner->type() == MIRType_Int32);
|
||||
phi->replaceOperand(i, inner);
|
||||
}
|
||||
|
||||
phi->setResultType(MIRType_Int32);
|
||||
}
|
||||
|
||||
// Examine all the users of |candidate| and determine the most aggressive
|
||||
// truncate kind that satisfies all of them.
|
||||
static MDefinition::TruncateKind
|
||||
@ -2585,8 +2621,11 @@ RangeAnalysis::truncate()
|
||||
|
||||
for (PostorderIterator block(graph_.poBegin()); block != graph_.poEnd(); block++) {
|
||||
for (MInstructionReverseIterator iter(block->rbegin()); iter != block->rend(); iter++) {
|
||||
if (iter->type() == MIRType_None)
|
||||
if (iter->type() == MIRType_None) {
|
||||
if (iter->isTest())
|
||||
TruncateTest(alloc(), iter->toTest());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remember all bitop instructions for folding after range analysis.
|
||||
switch (iter->op()) {
|
||||
|
Loading…
Reference in New Issue
Block a user