public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][1/2] Remove referenced vars
@ 2012-08-01 11:27 Richard Guenther
  2012-08-01 17:22 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Guenther @ 2012-08-01 11:27 UTC (permalink / raw)
  To: gcc-patches


This series aims at removing referenced vars.  It builds on the into-SSA
TLC series and the still to be posted removal of var-anns.

This first patch removes SRAs use of referenced vars.  Instead of
turning it upside-down the following simply adds a pass-local
"referenced" vars reverse lookup capability uid -> decl.

This was the last user of referenced_var ().

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

Richard.

2012-08-01  Richard Guenther  <rguenther@suse.de>

	* tree-flow-inline.h (referenced_var): Remove.
	* tree-ssa-coalesce.c (create_outofssa_var_map): Remove duplicate
	checking code.
	* tree-sra.c (candidates): New global hashtable.
	(candidate): New function.
	(sra_initialize): Initialize candidates.
	(sra_deinitialize): Free candidates.
	(disqualify_candidate): Remove candidate from candidates.
	(find_var_candidates): Walk over all local decls, add candidates
	to candidates hashtable.
	(find_param_candidates): Add candidates to candidates hashtable.
	(analyze_all_variable_accesses): Use candidate instead of
	referenced_var.

Index: gcc/tree-flow-inline.h
===================================================================
*** gcc/tree-flow-inline.h.orig	2012-08-01 11:06:15.000000000 +0200
--- gcc/tree-flow-inline.h	2012-08-01 11:16:46.398132279 +0200
*************** next_htab_element (htab_iterator *hti)
*** 98,113 ****
    return NULL;
  }
  
- /* Get the variable with uid UID from the list of referenced vars.  */
- 
- static inline tree
- referenced_var (unsigned int uid)
- {
-   tree var = referenced_var_lookup (cfun, uid);
-   gcc_assert (var || uid == 0);
-   return var;
- }
- 
  /* Initialize ITER to point to the first referenced variable in the
     referenced_vars hashtable, and return that variable.  */
  
--- 98,103 ----
Index: gcc/tree-ssa-coalesce.c
===================================================================
*** gcc/tree-ssa-coalesce.c.orig	2012-08-01 11:06:15.000000000 +0200
--- gcc/tree-ssa-coalesce.c	2012-08-01 11:16:46.399132279 +0200
*************** create_outofssa_var_map (coalesce_list_p
*** 983,996 ****
    int v1, v2, cost;
    unsigned i;
  
- #ifdef ENABLE_CHECKING
-   bitmap used_in_real_ops;
-   bitmap used_in_virtual_ops;
- 
-   used_in_real_ops = BITMAP_ALLOC (NULL);
-   used_in_virtual_ops = BITMAP_ALLOC (NULL);
- #endif
- 
    map = init_var_map (num_ssa_names);
  
    FOR_EACH_BB (bb)
--- 983,988 ----
*************** create_outofssa_var_map (coalesce_list_p
*** 1126,1142 ****
  	    default:
  	      break;
  	    }
- 
- #ifdef ENABLE_CHECKING
- 	  /* Mark real uses and defs.  */
- 	  FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE))
- 	    bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (var)));
- 
- 	  /* Validate that virtual ops don't get used in funny ways.  */
- 	  if (gimple_vuse (stmt))
- 	    bitmap_set_bit (used_in_virtual_ops,
- 			    DECL_UID (SSA_NAME_VAR (gimple_vuse (stmt))));
- #endif /* ENABLE_CHECKING */
  	}
      }
  
--- 1118,1123 ----
*************** create_outofssa_var_map (coalesce_list_p
*** 1173,1199 ****
  	}
      }
  
- #if defined ENABLE_CHECKING
-   {
-     unsigned i;
-     bitmap both = BITMAP_ALLOC (NULL);
-     bitmap_and (both, used_in_real_ops, used_in_virtual_ops);
-     if (!bitmap_empty_p (both))
-       {
- 	bitmap_iterator bi;
- 
- 	EXECUTE_IF_SET_IN_BITMAP (both, 0, i, bi)
- 	  fprintf (stderr, "Variable %s used in real and virtual operands\n",
- 		   get_name (referenced_var (i)));
- 	internal_error ("SSA corruption");
-       }
- 
-     BITMAP_FREE (used_in_real_ops);
-     BITMAP_FREE (used_in_virtual_ops);
-     BITMAP_FREE (both);
-   }
- #endif
- 
    return map;
  }
  
--- 1154,1159 ----
Index: gcc/tree-sra.c
===================================================================
*** gcc/tree-sra.c.orig	2012-08-01 11:16:45.000000000 +0200
--- gcc/tree-sra.c	2012-08-01 11:21:58.917121453 +0200
*************** struct access
*** 224,232 ****
       BIT_FIELD_REF?  */
    unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  We do
!      the decision and creation at different places because create_tmp_var
!      cannot be called from within FOR_EACH_REFERENCED_VAR. */
    unsigned grp_to_be_replaced : 1;
  
    /* Should TREE_NO_WARNING of a replacement be set?  */
--- 224,230 ----
       BIT_FIELD_REF?  */
    unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  */
    unsigned grp_to_be_replaced : 1;
  
    /* Should TREE_NO_WARNING of a replacement be set?  */
*************** static alloc_pool link_pool;
*** 269,276 ****
  /* Base (tree) -> Vector (VEC(access_p,heap) *) map.  */
  static struct pointer_map_t *base_access_vec;
  
! /* Bitmap of candidates.  */
  static bitmap candidate_bitmap;
  
  /* Bitmap of candidates which we should try to entirely scalarize away and
     those which cannot be (because they are and need be used as a whole).  */
--- 267,285 ----
  /* Base (tree) -> Vector (VEC(access_p,heap) *) map.  */
  static struct pointer_map_t *base_access_vec;
  
! /* Set of candidates.  */
  static bitmap candidate_bitmap;
+ static htab_t candidates;
+ 
+ /* For a candidate UID return the candidates decl.  */
+ 
+ static inline tree
+ candidate (unsigned uid)
+ {
+  struct tree_decl_minimal t;
+  t.uid = uid;
+  return (tree) htab_find_with_hash (candidates, &t, uid);
+ }
  
  /* Bitmap of candidates which we should try to entirely scalarize away and
     those which cannot be (because they are and need be used as a whole).  */
*************** static void
*** 600,605 ****
--- 609,616 ----
  sra_initialize (void)
  {
    candidate_bitmap = BITMAP_ALLOC (NULL);
+   candidates = htab_create (VEC_length (tree, cfun->local_decls) / 2,
+ 			    uid_decl_map_hash, uid_decl_map_eq, NULL);
    should_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
    cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
    gcc_obstack_init (&name_obstack);
*************** static void
*** 631,636 ****
--- 642,648 ----
  sra_deinitialize (void)
  {
    BITMAP_FREE (candidate_bitmap);
+   htab_delete (candidates);
    BITMAP_FREE (should_scalarize_away_bitmap);
    BITMAP_FREE (cannot_scalarize_away_bitmap);
    free_alloc_pool (access_pool);
*************** sra_deinitialize (void)
*** 646,652 ****
  static void
  disqualify_candidate (tree decl, const char *reason)
  {
!   bitmap_clear_bit (candidate_bitmap, DECL_UID (decl));
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
--- 658,667 ----
  static void
  disqualify_candidate (tree decl, const char *reason)
  {
!   if (bitmap_clear_bit (candidate_bitmap, DECL_UID (decl)))
!     htab_clear_slot (candidates,
! 		     htab_find_slot_with_hash (candidates, decl,
! 					       DECL_UID (decl), NO_INSERT));
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
*************** static bool
*** 1639,1649 ****
  find_var_candidates (void)
  {
    tree var, type;
!   referenced_var_iterator rvi;
    bool ret = false;
    const char *msg;
  
!   FOR_EACH_REFERENCED_VAR (cfun, var, rvi)
      {
        if (TREE_CODE (var) != VAR_DECL && TREE_CODE (var) != PARM_DECL)
          continue;
--- 1654,1665 ----
  find_var_candidates (void)
  {
    tree var, type;
!   unsigned int i;
    bool ret = false;
    const char *msg;
+   void **slot;
  
!   FOR_EACH_LOCAL_DECL (cfun, i, var)
      {
        if (TREE_CODE (var) != VAR_DECL && TREE_CODE (var) != PARM_DECL)
          continue;
*************** find_var_candidates (void)
*** 1695,1700 ****
--- 1711,1718 ----
  	}
  
        bitmap_set_bit (candidate_bitmap, DECL_UID (var));
+       slot = htab_find_slot_with_hash (candidates, var, DECL_UID (var), INSERT);
+       *slot = (void *) var;
  
        if (dump_file && (dump_flags & TDF_DETAILS))
  	{
*************** analyze_all_variable_accesses (void)
*** 2335,2341 ****
      if (bitmap_bit_p (should_scalarize_away_bitmap, i)
  	&& !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
        {
! 	tree var = referenced_var (i);
  
  	if (TREE_CODE (var) == VAR_DECL
  	    && type_consists_of_records_p (TREE_TYPE (var)))
--- 2353,2359 ----
      if (bitmap_bit_p (should_scalarize_away_bitmap, i)
  	&& !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
        {
! 	tree var = candidate (i);
  
  	if (TREE_CODE (var) == VAR_DECL
  	    && type_consists_of_records_p (TREE_TYPE (var)))
*************** analyze_all_variable_accesses (void)
*** 2363,2369 ****
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = referenced_var (i);
        struct access *access;
  
        access = sort_and_splice_var_accesses (var);
--- 2381,2387 ----
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = candidate (i);
        struct access *access;
  
        access = sort_and_splice_var_accesses (var);
*************** analyze_all_variable_accesses (void)
*** 2377,2383 ****
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = referenced_var (i);
        struct access *access = get_first_repr_for_decl (var);
  
        if (analyze_access_trees (access))
--- 2395,2401 ----
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = candidate (i);
        struct access *access = get_first_repr_for_decl (var);
  
        if (analyze_access_trees (access))
*************** find_param_candidates (void)
*** 3424,3429 ****
--- 3442,3448 ----
         parm = DECL_CHAIN (parm))
      {
        tree type = TREE_TYPE (parm);
+       void **slot;
  
        count++;
  
*************** find_param_candidates (void)
*** 3462,3467 ****
--- 3481,3490 ----
  	continue;
  
        bitmap_set_bit (candidate_bitmap, DECL_UID (parm));
+       slot = htab_find_slot_with_hash (candidates, parm,
+ 				       DECL_UID (parm), INSERT);
+       *slot = (void *) parm;
+ 
        ret = true;
        if (dump_file && (dump_flags & TDF_DETAILS))
  	{

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][1/2] Remove referenced vars
  2012-08-01 11:27 [PATCH][1/2] Remove referenced vars Richard Guenther
@ 2012-08-01 17:22 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2012-08-01 17:22 UTC (permalink / raw)
  To: gcc-patches

On Wed, 1 Aug 2012, Richard Guenther wrote:

> 
> This series aims at removing referenced vars.  It builds on the into-SSA
> TLC series and the still to be posted removal of var-anns.
> 
> This first patch removes SRAs use of referenced vars.  Instead of
> turning it upside-down the following simply adds a pass-local
> "referenced" vars reverse lookup capability uid -> decl.
> 
> This was the last user of referenced_var ().

The following is what I ended up applying after re-testing on
x86_64-unknown-linux-gnu.

Richard.

2012-08-01  Richard Guenther  <rguenther@suse.de>

	* tree-flow-inline.h (referenced_var): Remove.
	* tree-ssa-coalesce.c (create_outofssa_var_map): Remove duplicate
	checking code.
	* tree-sra.c (candidates): New global hashtable.
	(candidate): New function.
	(sra_initialize): Initialize candidates.
	(sra_deinitialize): Free candidates.
	(disqualify_candidate): Remove candidate from candidates.
	(maybe_add_sra_candidate): New function.
	(find_var_candidates): Walk over all local decls and parameters,
	add candidates to candidates hashtable.
	(find_param_candidates): Add candidates to candidates hashtable.
	(analyze_all_variable_accesses): Use candidate instead of
	referenced_var.

Index: gcc/tree-flow-inline.h
===================================================================
*** gcc/tree-flow-inline.h.orig	2012-08-01 17:04:18.000000000 +0200
--- gcc/tree-flow-inline.h	2012-08-01 17:14:40.874388765 +0200
*************** next_htab_element (htab_iterator *hti)
*** 98,113 ****
    return NULL;
  }
  
- /* Get the variable with uid UID from the list of referenced vars.  */
- 
- static inline tree
- referenced_var (unsigned int uid)
- {
-   tree var = referenced_var_lookup (cfun, uid);
-   gcc_assert (var || uid == 0);
-   return var;
- }
- 
  /* Initialize ITER to point to the first referenced variable in the
     referenced_vars hashtable, and return that variable.  */
  
--- 98,103 ----
Index: gcc/tree-ssa-coalesce.c
===================================================================
*** gcc/tree-ssa-coalesce.c.orig	2012-08-01 16:42:49.000000000 +0200
--- gcc/tree-ssa-coalesce.c	2012-08-01 17:14:40.874388765 +0200
*************** create_outofssa_var_map (coalesce_list_p
*** 983,996 ****
    int v1, v2, cost;
    unsigned i;
  
- #ifdef ENABLE_CHECKING
-   bitmap used_in_real_ops;
-   bitmap used_in_virtual_ops;
- 
-   used_in_real_ops = BITMAP_ALLOC (NULL);
-   used_in_virtual_ops = BITMAP_ALLOC (NULL);
- #endif
- 
    map = init_var_map (num_ssa_names);
  
    FOR_EACH_BB (bb)
--- 983,988 ----
*************** create_outofssa_var_map (coalesce_list_p
*** 1126,1142 ****
  	    default:
  	      break;
  	    }
- 
- #ifdef ENABLE_CHECKING
- 	  /* Mark real uses and defs.  */
- 	  FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE))
- 	    bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (var)));
- 
- 	  /* Validate that virtual ops don't get used in funny ways.  */
- 	  if (gimple_vuse (stmt))
- 	    bitmap_set_bit (used_in_virtual_ops,
- 			    DECL_UID (SSA_NAME_VAR (gimple_vuse (stmt))));
- #endif /* ENABLE_CHECKING */
  	}
      }
  
--- 1118,1123 ----
*************** create_outofssa_var_map (coalesce_list_p
*** 1173,1199 ****
  	}
      }
  
- #if defined ENABLE_CHECKING
-   {
-     unsigned i;
-     bitmap both = BITMAP_ALLOC (NULL);
-     bitmap_and (both, used_in_real_ops, used_in_virtual_ops);
-     if (!bitmap_empty_p (both))
-       {
- 	bitmap_iterator bi;
- 
- 	EXECUTE_IF_SET_IN_BITMAP (both, 0, i, bi)
- 	  fprintf (stderr, "Variable %s used in real and virtual operands\n",
- 		   get_name (referenced_var (i)));
- 	internal_error ("SSA corruption");
-       }
- 
-     BITMAP_FREE (used_in_real_ops);
-     BITMAP_FREE (used_in_virtual_ops);
-     BITMAP_FREE (both);
-   }
- #endif
- 
    return map;
  }
  
--- 1154,1159 ----
Index: gcc/tree-sra.c
===================================================================
*** gcc/tree-sra.c.orig	2012-08-01 16:42:49.000000000 +0200
--- gcc/tree-sra.c	2012-08-01 17:18:02.220381820 +0200
*************** struct access
*** 224,232 ****
       BIT_FIELD_REF?  */
    unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  We do
!      the decision and creation at different places because create_tmp_var
!      cannot be called from within FOR_EACH_REFERENCED_VAR. */
    unsigned grp_to_be_replaced : 1;
  
    /* Should TREE_NO_WARNING of a replacement be set?  */
--- 224,230 ----
       BIT_FIELD_REF?  */
    unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  */
    unsigned grp_to_be_replaced : 1;
  
    /* Should TREE_NO_WARNING of a replacement be set?  */
*************** static alloc_pool link_pool;
*** 269,276 ****
  /* Base (tree) -> Vector (VEC(access_p,heap) *) map.  */
  static struct pointer_map_t *base_access_vec;
  
! /* Bitmap of candidates.  */
  static bitmap candidate_bitmap;
  
  /* Bitmap of candidates which we should try to entirely scalarize away and
     those which cannot be (because they are and need be used as a whole).  */
--- 267,285 ----
  /* Base (tree) -> Vector (VEC(access_p,heap) *) map.  */
  static struct pointer_map_t *base_access_vec;
  
! /* Set of candidates.  */
  static bitmap candidate_bitmap;
+ static htab_t candidates;
+ 
+ /* For a candidate UID return the candidates decl.  */
+ 
+ static inline tree
+ candidate (unsigned uid)
+ {
+  struct tree_decl_minimal t;
+  t.uid = uid;
+  return (tree) htab_find_with_hash (candidates, &t, uid);
+ }
  
  /* Bitmap of candidates which we should try to entirely scalarize away and
     those which cannot be (because they are and need be used as a whole).  */
*************** static void
*** 600,605 ****
--- 609,616 ----
  sra_initialize (void)
  {
    candidate_bitmap = BITMAP_ALLOC (NULL);
+   candidates = htab_create (VEC_length (tree, cfun->local_decls) / 2,
+ 			    uid_decl_map_hash, uid_decl_map_eq, NULL);
    should_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
    cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
    gcc_obstack_init (&name_obstack);
*************** static void
*** 631,636 ****
--- 642,648 ----
  sra_deinitialize (void)
  {
    BITMAP_FREE (candidate_bitmap);
+   htab_delete (candidates);
    BITMAP_FREE (should_scalarize_away_bitmap);
    BITMAP_FREE (cannot_scalarize_away_bitmap);
    free_alloc_pool (access_pool);
*************** sra_deinitialize (void)
*** 646,652 ****
  static void
  disqualify_candidate (tree decl, const char *reason)
  {
!   bitmap_clear_bit (candidate_bitmap, DECL_UID (decl));
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
--- 658,667 ----
  static void
  disqualify_candidate (tree decl, const char *reason)
  {
!   if (bitmap_clear_bit (candidate_bitmap, DECL_UID (decl)))
!     htab_clear_slot (candidates,
! 		     htab_find_slot_with_hash (candidates, decl,
! 					       DECL_UID (decl), NO_INSERT));
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      {
*************** reject (tree var, const char *msg)
*** 1632,1708 ****
      }
  }
  
  /* The very first phase of intraprocedural SRA.  It marks in candidate_bitmap
     those with type which is suitable for scalarization.  */
  
  static bool
  find_var_candidates (void)
  {
!   tree var, type;
!   referenced_var_iterator rvi;
    bool ret = false;
-   const char *msg;
  
!   FOR_EACH_REFERENCED_VAR (cfun, var, rvi)
      {
!       if (TREE_CODE (var) != VAR_DECL && TREE_CODE (var) != PARM_DECL)
          continue;
-       type = TREE_TYPE (var);
- 
-       if (!AGGREGATE_TYPE_P (type)) 
-         {
-           reject (var, "not aggregate");
-           continue;
- 	}
-       if (needs_to_live_in_memory (var))
-         {
-           reject (var, "needs to live in memory");
-           continue;
-         }
-       if (TREE_THIS_VOLATILE (var))
-         {
-           reject (var, "is volatile");
- 	  continue;
-         }
-       if (!COMPLETE_TYPE_P (type))
-         {
-           reject (var, "has incomplete type");
- 	  continue;
-         }
-       if (!host_integerp (TYPE_SIZE (type), 1))
-         {
-           reject (var, "type size not fixed");
- 	  continue;
-         }
-       if (tree_low_cst (TYPE_SIZE (type), 1) == 0)
-         {
-           reject (var, "type size is zero");
-           continue;
-         }
-       if (type_internals_preclude_sra_p (type, &msg))
- 	{
- 	  reject (var, msg);
- 	  continue;
- 	}
-       if (/* Fix for PR 41089.  tree-stdarg.c needs to have va_lists intact but
- 	      we also want to schedule it rather late.  Thus we ignore it in
- 	      the early pass. */
- 	  (sra_mode == SRA_MODE_EARLY_INTRA
- 	      && is_va_list_type (type)))
-         {
- 	  reject (var, "is va_list");
- 	  continue;
- 	}
  
!       bitmap_set_bit (candidate_bitmap, DECL_UID (var));
! 
!       if (dump_file && (dump_flags & TDF_DETAILS))
! 	{
! 	  fprintf (dump_file, "Candidate (%d): ", DECL_UID (var));
! 	  print_generic_expr (dump_file, var, 0);
! 	  fprintf (dump_file, "\n");
! 	}
!       ret = true;
      }
  
    return ret;
--- 1647,1741 ----
      }
  }
  
+ /* Return true if VAR is a candidate for SRA.  */
+ 
+ static bool
+ maybe_add_sra_candidate (tree var)
+ {
+   tree type = TREE_TYPE (var);
+   const char *msg;
+   void **slot;
+ 
+   if (!AGGREGATE_TYPE_P (type)) 
+     {
+       reject (var, "not aggregate");
+       return false;
+     }
+   if (needs_to_live_in_memory (var))
+     {
+       reject (var, "needs to live in memory");
+       return false;
+     }
+   if (TREE_THIS_VOLATILE (var))
+     {
+       reject (var, "is volatile");
+       return false;
+     }
+   if (!COMPLETE_TYPE_P (type))
+     {
+       reject (var, "has incomplete type");
+       return false;
+     }
+   if (!host_integerp (TYPE_SIZE (type), 1))
+     {
+       reject (var, "type size not fixed");
+       return false;
+     }
+   if (tree_low_cst (TYPE_SIZE (type), 1) == 0)
+     {
+       reject (var, "type size is zero");
+       return false;
+     }
+   if (type_internals_preclude_sra_p (type, &msg))
+     {
+       reject (var, msg);
+       return false;
+     }
+   if (/* Fix for PR 41089.  tree-stdarg.c needs to have va_lists intact but
+ 	 we also want to schedule it rather late.  Thus we ignore it in
+ 	 the early pass. */
+       (sra_mode == SRA_MODE_EARLY_INTRA
+        && is_va_list_type (type)))
+     {
+       reject (var, "is va_list");
+       return false;
+     }
+ 
+   bitmap_set_bit (candidate_bitmap, DECL_UID (var));
+   slot = htab_find_slot_with_hash (candidates, var, DECL_UID (var), INSERT);
+   *slot = (void *) var;
+ 
+   if (dump_file && (dump_flags & TDF_DETAILS))
+     {
+       fprintf (dump_file, "Candidate (%d): ", DECL_UID (var));
+       print_generic_expr (dump_file, var, 0);
+       fprintf (dump_file, "\n");
+     }
+ 
+   return true;
+ }
+ 
  /* The very first phase of intraprocedural SRA.  It marks in candidate_bitmap
     those with type which is suitable for scalarization.  */
  
  static bool
  find_var_candidates (void)
  {
!   tree var, parm;
!   unsigned int i;
    bool ret = false;
  
!   for (parm = DECL_ARGUMENTS (current_function_decl);
!        parm;
!        parm = DECL_CHAIN (parm))
!     ret |= maybe_add_sra_candidate (parm);
! 
!   FOR_EACH_LOCAL_DECL (cfun, i, var)
      {
!       if (TREE_CODE (var) != VAR_DECL)
          continue;
  
!       ret |= maybe_add_sra_candidate (var);
      }
  
    return ret;
*************** analyze_all_variable_accesses (void)
*** 2335,2341 ****
      if (bitmap_bit_p (should_scalarize_away_bitmap, i)
  	&& !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
        {
! 	tree var = referenced_var (i);
  
  	if (TREE_CODE (var) == VAR_DECL
  	    && type_consists_of_records_p (TREE_TYPE (var)))
--- 2368,2374 ----
      if (bitmap_bit_p (should_scalarize_away_bitmap, i)
  	&& !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
        {
! 	tree var = candidate (i);
  
  	if (TREE_CODE (var) == VAR_DECL
  	    && type_consists_of_records_p (TREE_TYPE (var)))
*************** analyze_all_variable_accesses (void)
*** 2363,2369 ****
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = referenced_var (i);
        struct access *access;
  
        access = sort_and_splice_var_accesses (var);
--- 2396,2402 ----
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = candidate (i);
        struct access *access;
  
        access = sort_and_splice_var_accesses (var);
*************** analyze_all_variable_accesses (void)
*** 2377,2383 ****
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = referenced_var (i);
        struct access *access = get_first_repr_for_decl (var);
  
        if (analyze_access_trees (access))
--- 2410,2416 ----
    bitmap_copy (tmp, candidate_bitmap);
    EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
      {
!       tree var = candidate (i);
        struct access *access = get_first_repr_for_decl (var);
  
        if (analyze_access_trees (access))
*************** find_param_candidates (void)
*** 3424,3429 ****
--- 3457,3463 ----
         parm = DECL_CHAIN (parm))
      {
        tree type = TREE_TYPE (parm);
+       void **slot;
  
        count++;
  
*************** find_param_candidates (void)
*** 3462,3467 ****
--- 3496,3505 ----
  	continue;
  
        bitmap_set_bit (candidate_bitmap, DECL_UID (parm));
+       slot = htab_find_slot_with_hash (candidates, parm,
+ 				       DECL_UID (parm), INSERT);
+       *slot = (void *) parm;
+ 
        ret = true;
        if (dump_file && (dump_flags & TDF_DETAILS))
  	{

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-01 17:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 11:27 [PATCH][1/2] Remove referenced vars Richard Guenther
2012-08-01 17:22 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).