Simple recompute_reg_usage cleanup

Michael Hayes m.hayes@elec.canterbury.ac.nz
Thu Dec 2 19:38:00 GMT 1999


Jan Hubicka writes:

 > This part updates recompute_reg_usage to use loop_depth supplied by basic block
 > info instead of keeping track of it by it's own.
 > If this patch will be accepted, I will follow with similar patches to other passes.

FYI, I have been experimenting with a new field for each basic block
which records the innermost loop that the block is part of.  The loop
depth can then be derived using bb->loop->depth.

I have been trying to use this with the current loop optimiser but am
having trouble with insns that are not included in any basic block.


Anyway, here are the patches.

Michael.



Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.190
diff -c -3 -p -r1.190 flow.c
*** flow.c	1999/11/30 10:42:28	1.190
--- flow.c	1999/12/03 03:33:50
*************** struct basic_block_def entry_exit_blocks
*** 191,196 ****
--- 192,198 ----
      NULL,			/* aux */
      ENTRY_BLOCK,		/* index */
      0,				/* loop_depth */
+     NULL			/* loop */
      -1, -1			/* eh_beg, eh_end */
    },
    {
*************** struct basic_block_def entry_exit_blocks
*** 204,209 ****
--- 206,212 ----
      NULL,			/* aux */
      EXIT_BLOCK,			/* index */
      0,				/* loop_depth */
+     NULL			/* loop */
      -1, -1			/* eh_beg, eh_end */
    }
  };
*************** flow_loop_outside_edge_p (loop, e)
*** 7012,7015 ****
--- 7018,7043 ----
      abort ();
    return (e->src == ENTRY_BLOCK_PTR)
      || ! TEST_BIT (loop->nodes, e->src->index);
+ }
+ 
+ 
+ /* For each basic block record the innermost loop that it belongs to.  */
+ void
+ flow_loops_bb_record (loops)
+      struct loops *loops;
+ {
+   int i;
+ 
+   /* Scan the outermost loops first so that we record the innermost
+      loop last.  Perhaps it would be more efficient to scan the
+      innermost loops first and propagate this information to the outer
+      loops?  */
+   for (i = 0; i < loops->num; i++)
+     {
+       int node;
+       struct loop *loop = &loops->array[i];
+ 
+       EXECUTE_IF_SET_IN_SBITMAP (loop->nodes, 0, node, {
+ 	BASIC_BLOCK (node)->loop = loop;});
+     }
  }


Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/basic-block.h,v
retrieving revision 1.43
diff -c -3 -p -r1.43 basic-block.h
*** basic-block.h	1999/11/30 10:42:28	1.43
--- basic-block.h	1999/12/03 03:30:47
*************** typedef struct basic_block_def {
*** 159,164 ****
--- 159,167 ----
    /* The loop depth of this block plus one.  */
    int loop_depth;
  
+   /* The innermost loop this block belongs to or NULL.  */
+   struct loop *loop;
+ 
    /* The active eh region before head and after end.  */
    int eh_beg, eh_end;
  } *basic_block;
*************** extern struct basic_block_def entry_exit
*** 210,215 ****
--- 213,219 ----
  extern varray_type basic_block_for_insn;
  #define BLOCK_FOR_INSN(INSN)  VARRAY_BB (basic_block_for_insn, INSN_UID (INSN))
  #define BLOCK_NUM(INSN)	      (BLOCK_FOR_INSN (INSN)->index + 0)
+ #define LOOP_FOR_INSN(INSN)  (BLOCK_FOR_INSN (INSN)->loop)
  
  extern void compute_bb_for_insn		PROTO ((int));
  extern void set_block_for_insn		PROTO ((rtx, basic_block));
*************** struct loops
*** 308,314 ****
  extern int flow_loops_find PROTO ((struct loops *));
  extern void flow_loops_free PROTO ((struct loops *));
  extern void flow_loops_dump PROTO ((const struct loops *, FILE *, int));
! 
  
  /* This structure maintains an edge list vector.  */
  struct edge_list 
--- 353,359 ----
  extern int flow_loops_find PROTO ((struct loops *));
  extern void flow_loops_free PROTO ((struct loops *));
  extern void flow_loops_dump PROTO ((const struct loops *, FILE *, int));
! extern void flow_loops_bb_record PROTO ((struct loops *loops));
  
  /* This structure maintains an edge list vector.  */
  struct edge_list 



More information about the Gcc-patches mailing list