flow.c (compute_immediate_dominators): New function.
authorRichard Henderson <rth@cygnus.com>
Wed, 17 Mar 1999 21:58:49 +0000 (13:58 -0800)
committerJeff Law <law@gcc.gnu.org>
Wed, 17 Mar 1999 21:58:49 +0000 (14:58 -0700)
        * flow.c (compute_immediate_dominators): New function.
        * basic-block.h (compute_immediate_dominators): Declare it.

From-SVN: r25831

gcc/ChangeLog
gcc/basic-block.h
gcc/flow.c

index cccf21f3751b42e8173934662c65e0a67987c3fa..50681b290408b724fdec5f9fa342a17ce2b45ca4 100644 (file)
@@ -23,6 +23,9 @@ Wed Mar 17 18:20:24 1999  David S. Miller  <davem@redhat.com>
 
 Wed Mar 17 14:51:19 1999  Richard Henderson  <rth@cygnus.com>
 
+       * flow.c (compute_immediate_dominators): New function.
+       * basic-block.h (compute_immediate_dominators): Declare it.
+
        * alpha.h (HARD_REGNO_MODE_OK): Allow only 4 and 8 byte unit modes
        in FP regs.
        (MODES_TIEABLE_P): Define asymmetricly wrt modes illegal in FP regs.
index 2052b8c42ae725f360e7471679f41371ae8764b7..378577f1753950b2ebf1195bc6c158cb4696bed6 100644 (file)
@@ -249,3 +249,4 @@ extern void compute_preds_succs             PROTO ((int_list_ptr *, int_list_ptr *,
 extern void compute_dominators         PROTO ((sbitmap *, sbitmap *,
                                                int_list_ptr *,
                                                int_list_ptr *));
+extern void compute_immediate_dominators       PROTO ((int *, sbitmap *));
index 1e17112208e248c1a3dcb7bcf32370d78f0cbf67..267529639313fae3f1b919b8e5c3b4fa3aba44bc 100644 (file)
@@ -4560,6 +4560,46 @@ compute_dominators (dominators, post_dominators, s_preds, s_succs)
   free (temp_bitmap);
 }
 
+/* Given DOMINATORS, compute the immediate dominators into IDOM.  */
+
+void
+compute_immediate_dominators (idom, dominators)
+     int *idom;
+     sbitmap *dominators;
+{
+  sbitmap *tmp;
+  int b;
+
+  tmp = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
+
+  /* Begin with tmp(n) = dom(n) - { n }.  */
+  for (b = n_basic_blocks; --b >= 0; )
+    {
+      sbitmap_copy (tmp[b], dominators[b]);
+      RESET_BIT (tmp[b], b);
+    }
+
+  /* Subtract out all of our dominator's dominators.  */
+  for (b = n_basic_blocks; --b >= 0; )
+    {
+      sbitmap tmp_b = tmp[b];
+      int s;
+
+      for (s = n_basic_blocks; --s >= 0; )
+       if (TEST_BIT (tmp_b, s))
+         sbitmap_difference (tmp_b, tmp_b, tmp[s]);
+    }
+
+  /* Find the one bit set in the bitmap and put it in the output array.  */
+  for (b = n_basic_blocks; --b >= 0; )
+    {
+      int t;
+      EXECUTE_IF_SET_IN_SBITMAP (tmp[b], 0, t, { idom[b] = t; });
+    }
+
+  sbitmap_vector_free (tmp);
+}
+
 /* Count for a single SET rtx, X.  */
 
 static void