Don't generate phis if unnecessary (because this breaks the
critical-edge-splitting guarantee and causes insertion of phi copies to fail).
This commit is contained in:
parent
658db4ba71
commit
bfa65168e2
1 changed files with 23 additions and 7 deletions
|
@ -95,15 +95,31 @@ static void convert_block(struct basicblock* bb)
|
||||||
{
|
{
|
||||||
struct basicblock* outbb = pops.item[i].left;
|
struct basicblock* outbb = pops.item[i].left;
|
||||||
struct ir* ir = pops.item[i].right;
|
struct ir* ir = pops.item[i].right;
|
||||||
struct ir* phi = new_ir0(IR_PHI, ir->size);
|
|
||||||
|
|
||||||
for (j=0; j<pushes.count; j++)
|
assert(pushes.count > 0);
|
||||||
pmap_add(&phi->u.phivalue,
|
if (pushes.count == 1)
|
||||||
pushes.item[j].left,
|
{
|
||||||
pushes.item[j].right);
|
/* The push happened in exactly one place; that means we don't need a phi and can
|
||||||
phi->root = phi;
|
* just import the value directly. */
|
||||||
|
|
||||||
*ir = *phi;
|
struct ir* src = pushes.item[0].right;
|
||||||
|
ir->opcode = IR_NOP;
|
||||||
|
ir->left = src;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The push could have happened in one of several places; we need a phi. */
|
||||||
|
|
||||||
|
struct ir* phi = new_ir0(IR_PHI, ir->size);
|
||||||
|
for (j=0; j<pushes.count; j++)
|
||||||
|
{
|
||||||
|
pmap_add(&phi->u.phivalue,
|
||||||
|
pushes.item[j].left,
|
||||||
|
pushes.item[j].right);
|
||||||
|
}
|
||||||
|
phi->root = phi;
|
||||||
|
*ir = *phi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue