http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50183

--- Comment #10 from William J. Schmidt <wschmidt at gcc dot gnu.org> 
2011-09-13 16:40:05 UTC ---
The problem arises during canonicalization in the presence of nested loops. 
Loops are processed outward-in.  When each loop is processed, its single exit
edge's destination block is cleansed of duplicate close-phis.  The problem in
this case is that subsequent processing of the inner loop reintroduces
duplicate close-phis that are not then cleansed.

Specifically, block 43 contains the close-phis for the inner loop, and block 45
contains the close-phis for the outer loop:

<bb 43>:
  # err2.395_561 = PHI <err2.395_219(41)>
  # err2_lsm.820_573 = PHI <err2.395_219(41)>

...

<bb 45>:
  # err2.395_571 = PHI <err2.395_561(43)>
  # err2_lsm.820_574 = PHI <err2_lsm.820_573(43)>

...

When the outer loop is processed, the two close-phis are not duplicates (they
have different phi-arguments).  When the inner loop is processed, the two
close-phis are found to be duplicates.  The first is chosen as the
representative.  All immediate uses of err2_lsm.820_573 are replaced with uses
of err2.395_561, and the second phi in block 43 is removed.

The result is that block 45 now contains two duplicate close-phis.

I believe this can be easily fixed by checking whether a replaced immediate use
is itself a PHI statement with a single argument (a close-phi).  If so,
make_close_phi_nodes_unique () should be called again for the block containing
the replaced use.

I'll experiment with this.

Reply via email to