Well - this replaces passing down a flag pointer with a new member
in the partition struct.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-06-05  Richard Guenther  <rguent...@suse.de>

        * tree-loop-distribution.c (struct partition_s): Add has_writes
        member.
        (partition_alloc): Initialize it.
        (partition_has_writes): New function.
        (rdg_flag_uses): Adjust.
        (rdg_flag_vertex): Likewise.
        (rdg_flag_vertex_and_dependent): Likewise.
        (rdg_flag_loop_exits): Likewise.
        (build_rdg_partition_for_component): Likewise.
        (rdg_build_partitions): Likewise.

Index: trunk/gcc/tree-loop-distribution.c
===================================================================
*** trunk.orig/gcc/tree-loop-distribution.c     2012-06-05 11:45:32.000000000 
+0200
--- trunk/gcc/tree-loop-distribution.c  2012-06-05 11:50:38.656074822 +0200
*************** enum partition_kind { PKIND_NORMAL, PKIN
*** 57,62 ****
--- 57,63 ----
  typedef struct partition_s
  {
    bitmap stmts;
+   bool has_writes;
    enum partition_kind kind;
    /* Main statement a kind != PKIND_NORMAL partition is about.  */
    gimple main_stmt;
*************** partition_alloc (bitmap stmts)
*** 72,77 ****
--- 73,79 ----
  {
    partition_t partition = XCNEW (struct partition_s);
    partition->stmts = stmts ? stmts : BITMAP_ALLOC (NULL);
+   partition->has_writes = false;
    partition->kind = PKIND_NORMAL;
    return partition;
  }
*************** partition_builtin_p (partition_t partiti
*** 93,98 ****
--- 95,108 ----
    return partition->kind != PKIND_NORMAL;
  }
  
+ /* Returns true if the partition has an writes.  */
+ 
+ static bool
+ partition_has_writes (partition_t partition)
+ {
+   return partition->has_writes;
+ }
+ 
  /* If bit I is not set, it means that this node represents an
     operation that has already been performed, and that should not be
     performed again.  This is the subgraph of remaining important
*************** has_upstream_mem_writes (int u)
*** 583,596 ****
  }
  
  static void rdg_flag_vertex_and_dependent (struct graph *, int, partition_t,
!                                          bitmap, bitmap, bool *);
  
  /* Flag the uses of U stopping following the information from
     upstream_mem_writes.  */
  
  static void
  rdg_flag_uses (struct graph *rdg, int u, partition_t partition, bitmap loops,
!              bitmap processed, bool *part_has_writes)
  {
    use_operand_p use_p;
    struct vertex *x = &(rdg->vertices[u]);
--- 593,606 ----
  }
  
  static void rdg_flag_vertex_and_dependent (struct graph *, int, partition_t,
!                                          bitmap, bitmap);
  
  /* Flag the uses of U stopping following the information from
     upstream_mem_writes.  */
  
  static void
  rdg_flag_uses (struct graph *rdg, int u, partition_t partition, bitmap loops,
!              bitmap processed)
  {
    use_operand_p use_p;
    struct vertex *x = &(rdg->vertices[u]);
*************** rdg_flag_uses (struct graph *rdg, int u,
*** 606,612 ****
  
        if (!already_processed_vertex_p (processed, v))
        rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                      processed, part_has_writes);
      }
  
    if (gimple_code (stmt) != GIMPLE_PHI)
--- 616,622 ----
  
        if (!already_processed_vertex_p (processed, v))
        rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                      processed);
      }
  
    if (gimple_code (stmt) != GIMPLE_PHI)
*************** rdg_flag_uses (struct graph *rdg, int u,
*** 623,629 ****
              if (v >= 0
                  && !already_processed_vertex_p (processed, v))
                rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                              processed, part_has_writes);
            }
        }
      }
--- 633,639 ----
              if (v >= 0
                  && !already_processed_vertex_p (processed, v))
                rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                              processed);
            }
        }
      }
*************** rdg_flag_uses (struct graph *rdg, int u,
*** 645,651 ****
  
              if (!already_processed_vertex_p (processed, v))
                rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                              processed, part_has_writes);
            }
        }
      }
--- 655,661 ----
  
              if (!already_processed_vertex_p (processed, v))
                rdg_flag_vertex_and_dependent (rdg, v, partition, loops,
!                                              processed);
            }
        }
      }
*************** rdg_flag_uses (struct graph *rdg, int u,
*** 655,662 ****
     in LOOPS.  */
  
  static void
! rdg_flag_vertex (struct graph *rdg, int v, partition_t partition, bitmap 
loops,
!                bool *part_has_writes)
  {
    struct loop *loop;
  
--- 665,671 ----
     in LOOPS.  */
  
  static void
! rdg_flag_vertex (struct graph *rdg, int v, partition_t partition, bitmap 
loops)
  {
    struct loop *loop;
  
*************** rdg_flag_vertex (struct graph *rdg, int
*** 668,674 ****
  
    if (rdg_cannot_recompute_vertex_p (rdg, v))
      {
!       *part_has_writes = true;
        bitmap_clear_bit (remaining_stmts, v);
      }
  }
--- 677,683 ----
  
    if (rdg_cannot_recompute_vertex_p (rdg, v))
      {
!       partition->has_writes = true;
        bitmap_clear_bit (remaining_stmts, v);
      }
  }
*************** rdg_flag_vertex (struct graph *rdg, int
*** 678,699 ****
  
  static void
  rdg_flag_vertex_and_dependent (struct graph *rdg, int v, partition_t 
partition,
!                              bitmap loops, bitmap processed,
!                              bool *part_has_writes)
  {
    unsigned i;
    VEC (int, heap) *nodes = VEC_alloc (int, heap, 3);
    int x;
  
    bitmap_set_bit (processed, v);
!   rdg_flag_uses (rdg, v, partition, loops, processed, part_has_writes);
    graphds_dfs (rdg, &v, 1, &nodes, false, remaining_stmts);
!   rdg_flag_vertex (rdg, v, partition, loops, part_has_writes);
  
    FOR_EACH_VEC_ELT (int, nodes, i, x)
      if (!already_processed_vertex_p (processed, x))
!       rdg_flag_vertex_and_dependent (rdg, x, partition, loops, processed,
!                                    part_has_writes);
  
    VEC_free (int, heap, nodes);
  }
--- 687,706 ----
  
  static void
  rdg_flag_vertex_and_dependent (struct graph *rdg, int v, partition_t 
partition,
!                              bitmap loops, bitmap processed)
  {
    unsigned i;
    VEC (int, heap) *nodes = VEC_alloc (int, heap, 3);
    int x;
  
    bitmap_set_bit (processed, v);
!   rdg_flag_uses (rdg, v, partition, loops, processed);
    graphds_dfs (rdg, &v, 1, &nodes, false, remaining_stmts);
!   rdg_flag_vertex (rdg, v, partition, loops);
  
    FOR_EACH_VEC_ELT (int, nodes, i, x)
      if (!already_processed_vertex_p (processed, x))
!       rdg_flag_vertex_and_dependent (rdg, x, partition, loops, processed);
  
    VEC_free (int, heap, nodes);
  }
*************** collect_condition_stmts (struct loop *lo
*** 725,731 ****
  
  static void
  rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition,
!                    bitmap processed, bool *part_has_writes)
  {
    unsigned i;
    bitmap_iterator bi;
--- 732,738 ----
  
  static void
  rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition,
!                    bitmap processed)
  {
    unsigned i;
    bitmap_iterator bi;
*************** rdg_flag_loop_exits (struct graph *rdg,
*** 741,748 ****
        bitmap new_loops = BITMAP_ALLOC (NULL);
  
        if (!already_processed_vertex_p (processed, v))
!       rdg_flag_vertex_and_dependent (rdg, v, partition, new_loops, processed,
!                                      part_has_writes);
  
        EXECUTE_IF_SET_IN_BITMAP (new_loops, 0, i, bi)
        if (bitmap_set_bit (loops, i))
--- 748,754 ----
        bitmap new_loops = BITMAP_ALLOC (NULL);
  
        if (!already_processed_vertex_p (processed, v))
!       rdg_flag_vertex_and_dependent (rdg, v, partition, new_loops, processed);
  
        EXECUTE_IF_SET_IN_BITMAP (new_loops, 0, i, bi)
        if (bitmap_set_bit (loops, i))
*************** rdg_flag_loop_exits (struct graph *rdg,
*** 759,766 ****
     including the loop exit conditions.  */
  
  static partition_t
! build_rdg_partition_for_component (struct graph *rdg, rdgc c,
!                                  bool *part_has_writes)
  {
    int i, v;
    partition_t partition = partition_alloc (NULL);
--- 765,771 ----
     including the loop exit conditions.  */
  
  static partition_t
! build_rdg_partition_for_component (struct graph *rdg, rdgc c)
  {
    int i, v;
    partition_t partition = partition_alloc (NULL);
*************** build_rdg_partition_for_component (struc
*** 769,778 ****
  
    FOR_EACH_VEC_ELT (int, c->vertices, i, v)
      if (!already_processed_vertex_p (processed, v))
!       rdg_flag_vertex_and_dependent (rdg, v, partition, loops, processed,
!                                    part_has_writes);
  
!   rdg_flag_loop_exits (rdg, loops, partition, processed, part_has_writes);
  
    BITMAP_FREE (processed);
    BITMAP_FREE (loops);
--- 774,782 ----
  
    FOR_EACH_VEC_ELT (int, c->vertices, i, v)
      if (!already_processed_vertex_p (processed, v))
!       rdg_flag_vertex_and_dependent (rdg, v, partition, loops, processed);
  
!   rdg_flag_loop_exits (rdg, loops, partition, processed);
  
    BITMAP_FREE (processed);
    BITMAP_FREE (loops);
*************** rdg_build_partitions (struct graph *rdg,
*** 996,1013 ****
    FOR_EACH_VEC_ELT (rdgc, components, i, x)
      {
        partition_t np;
-       bool part_has_writes = false;
        int v = VEC_index (int, x->vertices, 0);
  
        if (bitmap_bit_p (processed, v))
        continue;
  
!       np = build_rdg_partition_for_component (rdg, x, &part_has_writes);
        bitmap_ior_into (partition->stmts, np->stmts);
        bitmap_ior_into (processed, np->stmts);
        partition_free (np);
  
!       if (part_has_writes)
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
            {
--- 1000,1017 ----
    FOR_EACH_VEC_ELT (rdgc, components, i, x)
      {
        partition_t np;
        int v = VEC_index (int, x->vertices, 0);
  
        if (bitmap_bit_p (processed, v))
        continue;
  
!       np = build_rdg_partition_for_component (rdg, x);
        bitmap_ior_into (partition->stmts, np->stmts);
+       partition->has_writes = partition_has_writes (np);
        bitmap_ior_into (processed, np->stmts);
        partition_free (np);
  
!       if (partition_has_writes (partition))
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
            {

Reply via email to