This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Insert on edge fix.


Whilst attempting to bootstrap with overlapping live ranges and
copyprop, I encountered a bootstrap problem when building the stage 3
compiler. (I hate those. At least it wasnt a verification error!)

The situation is:


BLOCK 0   
x_1 = blah;
if (cond)

BLOCK 1
  x_2 = blah2;

BLOCK 2
x_3 = PHI <x_1(0), x_2(1)>



well, it just so happens that copy prop replaces x_1 and x_2 with blah's
leaving us with:


BLOCK 0   
x_1 = blah;
if (cond)

BLOCK 1
  x_2 = blah2;

BLOCK 2
x_3 = PHI <blah(0), blah2(1)>

the SSA->Normal pass realizes it needs to insert stuff onto each edge,
but insert_on_edge doesn't do the (0,2) edge properly.

So, here's the changes to make insert_on_edge do the right thing.

If the else clause doesn't exist, then we'll create a new basic block
and make it the else clause. At the same time, I've added code to handle
insertions on the edges to the THEN and ELSE clauses when the edge it
critical. This can happen when the first stmt in the clause is a label,
and there exists a GOTO that label. 

Those are all the issues I was aware of for insert_on_edge, and I was
finally forced to deal with them :-)

There was also a blatent bug in bsi_insert_before. If you inserted at
the head of a basic block, it didn't update the BB head pointer. Not
sure how that was missed. I also added some code to check if we've
inserted at the head of a block which is pointed to by a LOOP_EXPR or
COND_EXPR, and update those pointers appropriately.

bootstrapped, verified, etc.

Andrew

Attachment: cfg.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]