------- Comment #8 from steven at gcc dot gnu dot org  2008-01-10 19:18 -------
We start with a CFG that looks like this (all edges directed down):

ENTRY
|
2
|\
| \
3  5
|\  \
| \  \
7  4--6
 \   /
  \ /
   8
   |
  EXIT

where basic block 4 is a forwarder block.  Insns in blocks 6 and 7 match and
are cross-jumped, to give a new CFG:

ENTRY
|
2
|\
| \
3  5
|\  \
| \  \
|  4--6
 \   /
  \ /
   7
   |
   8
   |
  EXIT

where basic blocks 4 *and* 6 are now forwarder blocks.  try_optimize_cfg then
removes the redundant forwarders, which results in the following simpler CFG:

ENTRY
|
2
|\
3 5
|/
7
|
EXIT

where basic blocks 3 and 5 have matching insns that could be cross-jumped,
except that there is a dead "(set (reg:CCZ 17 flags) (compare ...))" in the way
that the delete_trivially_dead_insns() call in cleanup_cfg() can obviously not
delete.  If that dead SET is deleted, blocks 3 and 5 are merged and we get the
same code as previous releases.

In pre-DF gcc releases, a liveness update would run a liveness update with dead
code elimination.  Copying that code from the GCC 4.2 release branch:

          /* Cleaning up CFG introduces more opportunities for dead code
             removal that in turn may introduce more opportunities for
             cleaning up the CFG.  */
          if (!update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
                                                 PROP_DEATH_NOTES
                                                 | PROP_SCAN_DEAD_CODE
                                                 | PROP_KILL_DEAD_CODE
                                                 | ((mode & CLEANUP_LOG_LINKS)
                                                    ? PROP_LOG_LINKS : 0)))

I don't believe we have to aggressively delete dead code on every cleanup_cfg()
iteration.  We did plenty experiments with that on the DF branch, and running
DCE all the time just loses in the cost/benefit trade-off.  As I've noted
before, we should remove dead code when it is beneficial.

In this case, when we remove the forwarder edges and turn a conditional jump
into a non-conditional jump, we should kill the code that computes the
condition if the condition is dead at the end of the basic block.  We can do
this if we have liveness information available during cleanup_cfg().


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2007-02-21 20:59:58         |2008-01-10 19:18:34
               date|                            |


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

Reply via email to