flow.c (compute_flow_dominators): Initially put all blocks on the worklist.
authorJeffrey A Law <law@cygnus.com>
Thu, 11 Nov 1999 09:21:12 +0000 (09:21 +0000)
committerJeff Law <law@gcc.gnu.org>
Thu, 11 Nov 1999 09:21:12 +0000 (02:21 -0700)
        * flow.c (compute_flow_dominators): Initially put all blocks on
        the worklist.
        * lcm.c (compute_antinout_edge, compute_available): Similarly.
        * gcse.c (compute_cprop_avinout): Remove.
        (compute_cprop_data): Use compute_available.
        (delete_null_pointer_checks_1): Use compute_available.

From-SVN: r30484

gcc/ChangeLog
gcc/flow.c
gcc/gcse.c
gcc/lcm.c

index d22e0683432c4465eb8c73b6a11a83138b80889c..7e410356911dbcf2161818e8d605922cc9fec8df 100644 (file)
@@ -4,6 +4,13 @@ Wed Nov 10 21:24:19 1999  Jason Eckhardt  <jle@cygnus.com>
 
 Wed Nov 10 15:56:16 1999  Jeffrey A Law  (law@cygnus.com)
 
+       * flow.c (compute_flow_dominators): Initially put all blocks on
+       the worklist.
+       * lcm.c (compute_antinout_edge, compute_available): Similarly.
+       * gcse.c (compute_cprop_avinout): Remove.
+       (compute_cprop_data): Use compute_available.
+       (delete_null_pointer_checks_1): Use compute_available.
+
        * basic-block.h (compute_available): Returns a void now.
        * gcse.c (one_classic_gcse_pass): Do not expect compute_available
        to return a value anymore.
index 96618b537e0f1f9e1d5c05cc0d1468af0409cc79..9ed2b35646a8eca4633a2c961c6761122328c072 100644 (file)
@@ -5339,24 +5339,21 @@ compute_flow_dominators (dominators, post_dominators)
 
   if (dominators)
     {
-      /* Clear the AUX field for each basic block.  */
+      /* The optimistic setting of dominators requires us to put every
+        block on the work list initially.  */
       for (bb = 0; bb < n_basic_blocks; bb++)
-       BASIC_BLOCK (bb)->aux = NULL;
+       {
+         *tos++ = BASIC_BLOCK (bb);
+         BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
+       }
 
       /* We want a maximal solution, so initially assume everything dominates
         everything else.  */
       sbitmap_vector_ones (dominators, n_basic_blocks);
 
-      /* Put the successors of the entry block on the worklist.  */
+      /* Mark successors of the entry block so we can identify them below.  */
       for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
-       {
-         *tos++ = e->dest;
-
-         /* We use the block's aux field to track blocks which are in
-            the worklist; we also use it to quickly determine which blocks
-            are successors of the ENTRY block.  */
-         e->dest->aux = ENTRY_BLOCK_PTR;
-       }
+       e->dest->aux = ENTRY_BLOCK_PTR;
 
       /* Iterate until the worklist is empty.  */
       while (tos != worklist)
@@ -5412,24 +5409,21 @@ compute_flow_dominators (dominators, post_dominators)
 
   if (post_dominators)
     {
-      /* Clear the AUX field for each basic block.  */
+      /* The optimistic setting of dominators requires us to put every
+        block on the work list initially.  */
       for (bb = 0; bb < n_basic_blocks; bb++)
-       BASIC_BLOCK (bb)->aux = NULL;
+       {
+         *tos++ = BASIC_BLOCK (bb);
+         BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
+       }
 
       /* We want a maximal solution, so initially assume everything post
         dominates everything else.  */
       sbitmap_vector_ones (post_dominators, n_basic_blocks);
 
-      /* Put the predecessors of the exit block on the worklist.  */
+      /* Mark predecessors of the exit block so we can identify them below.  */
       for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
-       {
-         *tos++ = e->src;
-
-         /* We use the block's aux field to track blocks which are in
-            the worklist; we also use it to quickly determine which blocks
-            are predecessors of the EXIT block.  */
-         e->src->aux = EXIT_BLOCK_PTR;
-       }
+       e->src->aux = EXIT_BLOCK_PTR;
 
       /* Iterate until the worklist is empty.  */
       while (tos != worklist)
index 7a01902e517b0fe6f802ceb7df1422bdeb1ae183..f1018d2c4adc74f922ccc09e624834a74446ab0f 100644 (file)
@@ -581,7 +581,6 @@ static void compute_transp      PROTO ((rtx, int, sbitmap *, int));
 static void compute_transpout      PROTO ((void));
 static void compute_local_properties  PROTO ((sbitmap *, sbitmap *,
                                              sbitmap *, int));
-static void compute_cprop_avinout     PROTO ((void));
 static void compute_cprop_data PROTO ((void));
 static void find_used_regs         PROTO ((rtx));
 static int try_replace_reg         PROTO ((rtx, rtx, rtx));
@@ -3591,40 +3590,6 @@ compute_transp (x, indx, bmap, set_p)
     }
 }
 
-/* Compute the available expressions at the start and end of each
-   basic block for cprop.  This particular dataflow equation is
-   used often enough that we might want to generalize it and make
-   as a subroutine for other global optimizations that need available
-   in/out information.  */
-static void
-compute_cprop_avinout ()
-{
-  int bb, changed, passes;
-
-  sbitmap_zero (cprop_avin[0]);
-  sbitmap_vector_ones (cprop_avout, n_basic_blocks);
-
-  passes = 0;
-  changed = 1;
-  while (changed)
-    {
-      changed = 0;
-      for (bb = 0; bb < n_basic_blocks; bb++)
-       {
-         if (bb != 0)
-           sbitmap_intersection_of_preds (cprop_avin[bb], cprop_avout, bb);
-         changed |= sbitmap_union_of_diff (cprop_avout[bb],
-                                           cprop_pavloc[bb],
-                                           cprop_avin[bb],
-                                           cprop_absaltered[bb]);
-       }
-      passes++;
-    }
-
-  if (gcse_file)
-    fprintf (gcse_file, "cprop avail expr computation: %d passes\n", passes);
-}
-
 /* Top level routine to do the dataflow analysis needed by copy/const
    propagation.  */
 
@@ -3632,7 +3597,8 @@ static void
 compute_cprop_data ()
 {
   compute_local_properties (cprop_absaltered, cprop_pavloc, NULL, 1);
-  compute_cprop_avinout ();
+  compute_available (cprop_pavloc, cprop_absaltered,
+                    cprop_avout, cprop_avin);
 }
 \f
 /* Copy/constant propagation.  */
@@ -5030,7 +4996,7 @@ delete_null_pointer_checks_1 (s_preds, block_reg, nonnull_avin,
      sbitmap *nonnull_avout;
      struct null_pointer_info *npi;
 {
-  int changed, bb;
+  int bb;
   int current_block;
   sbitmap *nonnull_local = npi->nonnull_local;
   sbitmap *nonnull_killed = npi->nonnull_killed;
@@ -5103,25 +5069,8 @@ delete_null_pointer_checks_1 (s_preds, block_reg, nonnull_avin,
 
   /* Now compute global properties based on the local properties.   This
      is a classic global availablity algorithm.  */
-  sbitmap_zero (nonnull_avin[0]);
-  sbitmap_vector_ones (nonnull_avout, n_basic_blocks);
-  changed = 1;
-  while (changed)
-    {
-      changed = 0;
-
-      for (bb = 0; bb < n_basic_blocks; bb++)
-       {
-         if (bb != 0)
-           sbitmap_intersect_of_predecessors (nonnull_avin[bb],
-                                              nonnull_avout, bb, s_preds);
-
-         changed |= sbitmap_union_of_diff (nonnull_avout[bb],
-                                           nonnull_local[bb],
-                                           nonnull_avin[bb],
-                                           nonnull_killed[bb]);
-       }
-    }
+  compute_available (nonnull_local, nonnull_killed,
+                    nonnull_avout, nonnull_avin);
 
   /* Now look at each bb and see if it ends with a compare of a value
      against zero.  */
index 4df804060aff5e8f2a08b236420b3c8aea8548fd..12a16ed87c096fe0d07076f9e74498f12ffc1dd2 100644 (file)
--- a/gcc/lcm.c
+++ b/gcc/lcm.c
@@ -112,17 +112,19 @@ compute_antinout_edge (antloc, transp, antin, antout)
      ANTIN.  */
   sbitmap_vector_ones (antin, n_basic_blocks);
 
-  /* Put the predecessors of the exit block on the worklist.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  /* Put every block on the worklist; this is necessary because of the
+     optimistic initialization of ANTIN above.  */
+  for (bb = 0; bb < n_basic_blocks; bb++)
     {
-      *tos++ = e->src;
-
-      /* We use the block's aux field to track blocks which are in
-        the worklist; we also use it to quickly determine which blocks
-        are predecessors of the EXIT block.  */
-      e->src->aux = EXIT_BLOCK_PTR;
+      *tos++ = BASIC_BLOCK (bb);
+      BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
     }
 
+  /* Mark blocks which are predecessors of the exit block so that we
+     can easily identify them below.  */
+  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+    e->src->aux = EXIT_BLOCK_PTR;
+
   /* Iterate until the worklist is empty.  */
   while (tos != worklist)
     {
@@ -467,17 +469,19 @@ compute_available (avloc, kill, avout, avin)
   /* We want a maximal solution.  */
   sbitmap_vector_ones (avout, n_basic_blocks);
 
-  /* Put the successors of the entry block on the worklist.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  /* Put every block on the worklist; this is necessary because of the
+     optimistic initialization of AVOUT above.  */
+  for (bb = n_basic_blocks - 1; bb >= 0; bb--)
     {
-      *tos++ = e->dest;
-
-      /* We use the block's aux field to track blocks which are in
-        the worklist; we also use it to quickly determine which blocks
-        are successors of the ENTRY block.  */
-      e->dest->aux = ENTRY_BLOCK_PTR;
+      *tos++ = BASIC_BLOCK (bb);
+      BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
     }
 
+  /* Mark blocks which are successors of the entry block so that we
+     can easily identify them below.  */
+  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+    e->dest->aux = ENTRY_BLOCK_PTR;
+
   /* Iterate until the worklist is empty.  */
   while (tos != worklist)
     {