[patch] Remove loop_data from ivopts

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Feb 9 18:29:00 GMT 2006


Hello,

ivopts store some information (number of used registers) in loop->aux.
This actually is not useful, as ivopts only need it for the current
loop (it is a remnant of a very old experiment for that I
decided that it is not worth the extra compile time costs, in the end).
This patch moves the regs_used field to the common structure where
all the data for the current loop are kept.

Bootstrapped & regtested on i686.

Zdenek

	* tree-ssa-loop-ivopts.c (struct loop_data, loop_data): Removed.
	(struct ivopts_data): Add regs_used field.
	(tree_ssa_iv_optimize_init): Do not allocate aux fields for loops.
	(ivopts_global_cost_for_size, determine_set_costs): Use data->regs_used
	instead of loop_data->regs_used;
	(free_loop_data): Do not free aux fields for loops.
	(tree_ssa_iv_optimize): Do not pass loops to tree_ssa_iv_optimize_init
	and tree_ssa_iv_optimize_finalize.

Index: tree-ssa-loop-ivopts.c
===================================================================
*** tree-ssa-loop-ivopts.c	(revision 110773)
--- tree-ssa-loop-ivopts.c	(working copy)
*************** struct version_info
*** 121,132 ****
    bool preserve_biv;	/* For the original biv, whether to preserve it.  */
  };
  
- /* Information attached to loop.  */
- struct loop_data
- {
-   unsigned regs_used;	/* Number of registers used.  */
- };
- 
  /* Types of uses.  */
  enum use_type
  {
--- 121,126 ----
*************** struct ivopts_data
*** 209,214 ****
--- 203,211 ----
    /* The currently optimized loop.  */
    struct loop *current_loop;
  
+   /* Number of registers used in it.  */
+   unsigned regs_used;
+ 
    /* Numbers of iterations for all exits of the current loop.  */
    htab_t niters;
  
*************** iv_cand (struct ivopts_data *data, unsig
*** 347,360 ****
    return VEC_index (iv_cand_p, data->iv_candidates, i);
  }
  
- /* The data for LOOP.  */
- 
- static inline struct loop_data *
- loop_data (struct loop *loop)
- {
-   return loop->aux;
- }
- 
  /* The single loop exit if it dominates the latch, NULL otherwise.  */
  
  edge
--- 344,349 ----
*************** niter_for_single_dom_exit (struct ivopts
*** 736,759 ****
  }
  
  /* Initializes data structures used by the iv optimization pass, stored
!    in DATA.  LOOPS is the loop tree.  */
  
  static void
! tree_ssa_iv_optimize_init (struct loops *loops, struct ivopts_data *data)
  {
-   unsigned i;
- 
    data->version_info_size = 2 * num_ssa_names;
    data->version_info = XCNEWVEC (struct version_info, data->version_info_size);
    data->relevant = BITMAP_ALLOC (NULL);
    data->important_candidates = BITMAP_ALLOC (NULL);
    data->max_inv_id = 0;
    data->niters = htab_create (10, nfe_hash, nfe_eq, free);
- 
-   for (i = 1; i < loops->num; i++)
-     if (loops->parray[i])
-       loops->parray[i]->aux = xcalloc (1, sizeof (struct loop_data));
- 
    data->iv_uses = VEC_alloc (iv_use_p, heap, 20);
    data->iv_candidates = VEC_alloc (iv_cand_p, heap, 20);
    decl_rtl_to_reset = VEC_alloc (tree, heap, 20);
--- 725,741 ----
  }
  
  /* Initializes data structures used by the iv optimization pass, stored
!    in DATA.  */
  
  static void
! tree_ssa_iv_optimize_init (struct ivopts_data *data)
  {
    data->version_info_size = 2 * num_ssa_names;
    data->version_info = XCNEWVEC (struct version_info, data->version_info_size);
    data->relevant = BITMAP_ALLOC (NULL);
    data->important_candidates = BITMAP_ALLOC (NULL);
    data->max_inv_id = 0;
    data->niters = htab_create (10, nfe_hash, nfe_eq, free);
    data->iv_uses = VEC_alloc (iv_use_p, heap, 20);
    data->iv_candidates = VEC_alloc (iv_cand_p, heap, 20);
    decl_rtl_to_reset = VEC_alloc (tree, heap, 20);
*************** if (dump_file && (dump_flags & TDF_DETAI
*** 4227,4235 ****
  static unsigned
  ivopts_global_cost_for_size (struct ivopts_data *data, unsigned size)
  {
!   return global_cost_for_size (size,
! 			       loop_data (data->current_loop)->regs_used,
! 			       n_iv_uses (data));
  }
  
  /* For each size of the induction variable set determine the penalty.  */
--- 4209,4215 ----
  static unsigned
  ivopts_global_cost_for_size (struct ivopts_data *data, unsigned size)
  {
!   return global_cost_for_size (size, data->regs_used, n_iv_uses (data));
  }
  
  /* For each size of the induction variable set determine the penalty.  */
*************** determine_set_costs (struct ivopts_data 
*** 4293,4299 ****
  	n++;
      }
  
!   loop_data (loop)->regs_used = n;
    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "  regs_used %d\n", n);
  
--- 4273,4279 ----
  	n++;
      }
  
!   data->regs_used = n;
    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "  regs_used %d\n", n);
  
*************** free_loop_data (struct ivopts_data *data
*** 5718,5734 ****
     loop tree.  */
  
  static void
! tree_ssa_iv_optimize_finalize (struct loops *loops, struct ivopts_data *data)
  {
-   unsigned i;
- 
-   for (i = 1; i < loops->num; i++)
-     if (loops->parray[i])
-       {
- 	free (loops->parray[i]->aux);
- 	loops->parray[i]->aux = NULL;
-       }
- 
    free_loop_data (data);
    free (data->version_info);
    BITMAP_FREE (data->relevant);
--- 5698,5705 ----
     loop tree.  */
  
  static void
! tree_ssa_iv_optimize_finalize (struct ivopts_data *data)
  {
    free_loop_data (data);
    free (data->version_info);
    BITMAP_FREE (data->relevant);
*************** tree_ssa_iv_optimize (struct loops *loop
*** 5820,5826 ****
    struct loop *loop;
    struct ivopts_data data;
  
!   tree_ssa_iv_optimize_init (loops, &data);
  
    /* Optimize the loops starting with the innermost ones.  */
    loop = loops->tree_root;
--- 5791,5797 ----
    struct loop *loop;
    struct ivopts_data data;
  
!   tree_ssa_iv_optimize_init (&data);
  
    /* Optimize the loops starting with the innermost ones.  */
    loop = loops->tree_root;
*************** tree_ssa_iv_optimize (struct loops *loop
*** 5845,5849 ****
  	loop = loop->outer;
      }
  
!   tree_ssa_iv_optimize_finalize (loops, &data);
  }
--- 5816,5820 ----
  	loop = loop->outer;
      }
  
!   tree_ssa_iv_optimize_finalize (&data);
  }



More information about the Gcc-patches mailing list