Commit d94b820b by Richard Guenther Committed by Richard Biener

tree-flow-inline.h (referenced_var): Remove.

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.

From-SVN: r190047
parent ece401ee
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.
2012-08-01 Tom de Vries <tom@codesourcery.com> 2012-08-01 Tom de Vries <tom@codesourcery.com>
* tree-vrp.c (find_case_label_ranges): New function. * tree-vrp.c (find_case_label_ranges): New function.
......
...@@ -98,16 +98,6 @@ next_htab_element (htab_iterator *hti) ...@@ -98,16 +98,6 @@ next_htab_element (htab_iterator *hti)
return NULL; 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 /* Initialize ITER to point to the first referenced variable in the
referenced_vars hashtable, and return that variable. */ referenced_vars hashtable, and return that variable. */
......
...@@ -224,9 +224,7 @@ struct access ...@@ -224,9 +224,7 @@ struct access
BIT_FIELD_REF? */ BIT_FIELD_REF? */
unsigned grp_partial_lhs : 1; unsigned grp_partial_lhs : 1;
/* Set when a scalar replacement should be created for this variable. We do /* Set when a scalar replacement should be created for this variable. */
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; unsigned grp_to_be_replaced : 1;
/* Should TREE_NO_WARNING of a replacement be set? */ /* Should TREE_NO_WARNING of a replacement be set? */
...@@ -269,8 +267,19 @@ static alloc_pool link_pool; ...@@ -269,8 +267,19 @@ static alloc_pool link_pool;
/* Base (tree) -> Vector (VEC(access_p,heap) *) map. */ /* Base (tree) -> Vector (VEC(access_p,heap) *) map. */
static struct pointer_map_t *base_access_vec; static struct pointer_map_t *base_access_vec;
/* Bitmap of candidates. */ /* Set of candidates. */
static bitmap candidate_bitmap; 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 /* 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). */ those which cannot be (because they are and need be used as a whole). */
...@@ -600,6 +609,8 @@ static void ...@@ -600,6 +609,8 @@ static void
sra_initialize (void) sra_initialize (void)
{ {
candidate_bitmap = BITMAP_ALLOC (NULL); 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); should_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL); cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
gcc_obstack_init (&name_obstack); gcc_obstack_init (&name_obstack);
...@@ -631,6 +642,7 @@ static void ...@@ -631,6 +642,7 @@ static void
sra_deinitialize (void) sra_deinitialize (void)
{ {
BITMAP_FREE (candidate_bitmap); BITMAP_FREE (candidate_bitmap);
htab_delete (candidates);
BITMAP_FREE (should_scalarize_away_bitmap); BITMAP_FREE (should_scalarize_away_bitmap);
BITMAP_FREE (cannot_scalarize_away_bitmap); BITMAP_FREE (cannot_scalarize_away_bitmap);
free_alloc_pool (access_pool); free_alloc_pool (access_pool);
...@@ -646,7 +658,10 @@ sra_deinitialize (void) ...@@ -646,7 +658,10 @@ sra_deinitialize (void)
static void static void
disqualify_candidate (tree decl, const char *reason) disqualify_candidate (tree decl, const char *reason)
{ {
bitmap_clear_bit (candidate_bitmap, DECL_UID (decl)); 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)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
...@@ -1632,77 +1647,95 @@ reject (tree var, const char *msg) ...@@ -1632,77 +1647,95 @@ reject (tree var, const char *msg)
} }
} }
/* 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 /* The very first phase of intraprocedural SRA. It marks in candidate_bitmap
those with type which is suitable for scalarization. */ those with type which is suitable for scalarization. */
static bool static bool
find_var_candidates (void) find_var_candidates (void)
{ {
tree var, type; tree var, parm;
referenced_var_iterator rvi; unsigned int i;
bool ret = false; bool ret = false;
const char *msg;
FOR_EACH_REFERENCED_VAR (cfun, var, rvi) 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 && TREE_CODE (var) != PARM_DECL) if (TREE_CODE (var) != VAR_DECL)
continue; continue;
type = TREE_TYPE (var);
if (!AGGREGATE_TYPE_P (type)) ret |= maybe_add_sra_candidate (var);
{
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; return ret;
...@@ -2335,7 +2368,7 @@ analyze_all_variable_accesses (void) ...@@ -2335,7 +2368,7 @@ analyze_all_variable_accesses (void)
if (bitmap_bit_p (should_scalarize_away_bitmap, i) if (bitmap_bit_p (should_scalarize_away_bitmap, i)
&& !bitmap_bit_p (cannot_scalarize_away_bitmap, i)) && !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
{ {
tree var = referenced_var (i); tree var = candidate (i);
if (TREE_CODE (var) == VAR_DECL if (TREE_CODE (var) == VAR_DECL
&& type_consists_of_records_p (TREE_TYPE (var))) && type_consists_of_records_p (TREE_TYPE (var)))
...@@ -2363,7 +2396,7 @@ analyze_all_variable_accesses (void) ...@@ -2363,7 +2396,7 @@ analyze_all_variable_accesses (void)
bitmap_copy (tmp, candidate_bitmap); bitmap_copy (tmp, candidate_bitmap);
EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
{ {
tree var = referenced_var (i); tree var = candidate (i);
struct access *access; struct access *access;
access = sort_and_splice_var_accesses (var); access = sort_and_splice_var_accesses (var);
...@@ -2377,7 +2410,7 @@ analyze_all_variable_accesses (void) ...@@ -2377,7 +2410,7 @@ analyze_all_variable_accesses (void)
bitmap_copy (tmp, candidate_bitmap); bitmap_copy (tmp, candidate_bitmap);
EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
{ {
tree var = referenced_var (i); tree var = candidate (i);
struct access *access = get_first_repr_for_decl (var); struct access *access = get_first_repr_for_decl (var);
if (analyze_access_trees (access)) if (analyze_access_trees (access))
...@@ -3424,6 +3457,7 @@ find_param_candidates (void) ...@@ -3424,6 +3457,7 @@ find_param_candidates (void)
parm = DECL_CHAIN (parm)) parm = DECL_CHAIN (parm))
{ {
tree type = TREE_TYPE (parm); tree type = TREE_TYPE (parm);
void **slot;
count++; count++;
...@@ -3462,6 +3496,10 @@ find_param_candidates (void) ...@@ -3462,6 +3496,10 @@ find_param_candidates (void)
continue; continue;
bitmap_set_bit (candidate_bitmap, DECL_UID (parm)); 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; ret = true;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
......
...@@ -983,14 +983,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) ...@@ -983,14 +983,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
int v1, v2, cost; int v1, v2, cost;
unsigned i; 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); map = init_var_map (num_ssa_names);
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
...@@ -1126,17 +1118,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) ...@@ -1126,17 +1118,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
default: default:
break; 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 */
} }
} }
...@@ -1173,27 +1154,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) ...@@ -1173,27 +1154,6 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
} }
} }
#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; return map;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment