Commit 07bd6227 by Richard Guenther Committed by Richard Biener

tree-ssa-operands.c (add_vars_for_offset): Clean and speed up.

2007-10-28  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-operands.c (add_vars_for_offset): Clean and speed up.
	(add_vars_for_bitmap): Do not recurse further.  Only add vars
	for pointed-to SFTs.
	(add_virtual_operand): Re-instantiate loop to add operands for
	aliases.  Recurse into MPTs.
	(get_indirect_ref_operands): If we fall back to use a pointers
	SMT, make sure to not prune based on the access offset and size.

From-SVN: r129702
parent 5cb41805
2007-10-28 Richard Guenther <rguenther@suse.de>
* tree-ssa-operands.c (add_vars_for_offset): Clean and speed up.
(add_vars_for_bitmap): Do not recurse further. Only add vars
for pointed-to SFTs.
(add_virtual_operand): Re-instantiate loop to add operands for
aliases. Recurse into MPTs.
(get_indirect_ref_operands): If we fall back to use a pointers
SMT, make sure to not prune based on the access offset and size.
2007-10-28 Andrew Pinski <pinskia@gmail.com> 2007-10-28 Andrew Pinski <pinskia@gmail.com>
PR tree-opt/33589 PR tree-opt/33589
...@@ -1392,23 +1392,27 @@ static bool ...@@ -1392,23 +1392,27 @@ static bool
add_vars_for_offset (tree full_ref, tree var, HOST_WIDE_INT offset, add_vars_for_offset (tree full_ref, tree var, HOST_WIDE_INT offset,
HOST_WIDE_INT size, bool is_call_site, bool is_def) HOST_WIDE_INT size, bool is_call_site, bool is_def)
{ {
bool added = false;
subvar_t sv;
unsigned int i;
tree subvar;
/* Call-clobbered tags may have non-call-clobbered /* Call-clobbered tags may have non-call-clobbered
symbols in their alias sets. Ignore them if we are symbols in their alias sets. Ignore them if we are
adding VOPs for a call site. */ adding VOPs for a call site. */
if (is_call_site && !is_call_clobbered (var)) if (is_call_site && !is_call_clobbered (var))
return false; return false;
/* For offset 0, we already have the right variable. If there is no /* For SFTs we have to consider all subvariables of the parent var. */
full_ref, this is not a place we care about (All component if (TREE_CODE (var) != STRUCT_FIELD_TAG)
related accesses that go through pointers will have full_ref not {
NULL). /* If we do not know the full reference tree or if the access is
Any var for which we didn't create SFT's can't be unspecified [0, -1], we cannot prune it. Otherwise try doing
distinguished. */ so using access_can_touch_variable. */
if (!full_ref || (offset == 0 && size != -1) if (full_ref
|| (TREE_CODE (var) != STRUCT_FIELD_TAG && !(offset == 0 && size == -1)
&& (!var_can_have_subvars (var) || !get_subvars_for_var (var)))) && !access_can_touch_variable (full_ref, var, offset, size))
{
if (!access_can_touch_variable (full_ref, var, offset, size))
return false; return false;
if (is_def) if (is_def)
...@@ -1417,40 +1421,33 @@ add_vars_for_offset (tree full_ref, tree var, HOST_WIDE_INT offset, ...@@ -1417,40 +1421,33 @@ add_vars_for_offset (tree full_ref, tree var, HOST_WIDE_INT offset,
append_vuse (var); append_vuse (var);
return true; return true;
} }
else if (TREE_CODE (var) == STRUCT_FIELD_TAG)
{
bool added = false;
subvar_t sv = get_subvars_for_var (SFT_PARENT_VAR (var));
unsigned int i;
tree subvar;
for (i = 0; VEC_iterate (tree, sv, i, subvar); ++i) sv = get_subvars_for_var (SFT_PARENT_VAR (var));
for (i = 0; VEC_iterate (tree, sv, i, subvar); ++i)
{
/* Once we hit the end of the parts that could touch,
stop looking. */
if (size != -1
&& SFT_OFFSET (var) + offset + size <= SFT_OFFSET (subvar))
break;
if (overlap_subvar (SFT_OFFSET (var) + offset, size, subvar, NULL))
{ {
/* Once we hit the end of the parts that could touch, added = true;
stop looking. */ if (is_def)
if (size != -1 append_vdef (subvar);
&& SFT_OFFSET (var) + offset + size <= SFT_OFFSET (subvar)) else
break; append_vuse (subvar);
if (overlap_subvar (SFT_OFFSET (var) + offset, size, subvar, NULL))
{
added = true;
if (is_def)
append_vdef (subvar);
else
append_vuse (subvar);
}
} }
return added;
} }
return added;
return false;
} }
/* Add all aliases from ALIASES as virtual operands for the access /* Consider all SFTs in ALIASES as points-to location and add virtual
FULL_REF at OFFSET and size SIZE. IS_CALL_SITE is true if the operands for the SFT parent var for the access FULL_REF at OFFSET
stmt of the reference is a call. IS_DEF is true if we should add and size SIZE. IS_CALL_SITE is true if the stmt of the reference is
VDEF virtual operands, otherwise we'll add VUSEs. *NONE_ADDED a call. IS_DEF is true if we should add VDEF virtual operands,
is set to false once the first virtual operand was added. */ otherwise we'll add VUSEs. *NONE_ADDED is set to false once the first
virtual operand was added. */
static void static void
add_vars_for_bitmap (bitmap aliases, tree full_ref, add_vars_for_bitmap (bitmap aliases, tree full_ref,
...@@ -1464,10 +1461,9 @@ add_vars_for_bitmap (bitmap aliases, tree full_ref, ...@@ -1464,10 +1461,9 @@ add_vars_for_bitmap (bitmap aliases, tree full_ref,
{ {
tree al = referenced_var (i); tree al = referenced_var (i);
if (TREE_CODE (al) == MEMORY_PARTITION_TAG) gcc_assert (TREE_CODE (al) != MEMORY_PARTITION_TAG);
add_vars_for_bitmap (MPT_SYMBOLS (al), full_ref,
offset, size, is_call_site, is_def, none_added); if (TREE_CODE (al) == STRUCT_FIELD_TAG)
else
*none_added &= !add_vars_for_offset (full_ref, al, offset, size, *none_added &= !add_vars_for_offset (full_ref, al, offset, size,
is_call_site, is_def); is_call_site, is_def);
} }
...@@ -1535,14 +1531,28 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags, ...@@ -1535,14 +1531,28 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
} }
else else
{ {
bitmap_iterator bi;
unsigned int i;
bool none_added = true; bool none_added = true;
/* The variable is aliased. Add its aliases to the virtual /* The variable is aliased. Add its aliases to the virtual
operands. */ operands. */
gcc_assert (!bitmap_empty_p (aliases)); gcc_assert (!bitmap_empty_p (aliases));
add_vars_for_bitmap (aliases, full_ref, offset, size, EXECUTE_IF_SET_IN_BITMAP (aliases, 0, i, bi)
is_call_site, flags & opf_def, &none_added); {
tree al = referenced_var (i);
/* We have to consider SFTs inside MPTs as possible pointed-to
location as well because even if aliases does not contain
a single SFT, the SFTs inside the MPT may be incomplete in
that not all aliased subvars have to be in this MPT, too. */
if (TREE_CODE (al) == MEMORY_PARTITION_TAG)
add_vars_for_bitmap (MPT_SYMBOLS (al), full_ref, offset, size,
is_call_site, flags & opf_def, &none_added);
none_added &= !add_vars_for_offset (full_ref, al, offset, size,
is_call_site, flags & opf_def);
}
if (flags & opf_def) if (flags & opf_def)
{ {
...@@ -1680,9 +1690,12 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags, ...@@ -1680,9 +1690,12 @@ get_indirect_ref_operands (tree stmt, tree expr, int flags,
ptr = SSA_NAME_VAR (ptr); ptr = SSA_NAME_VAR (ptr);
v_ann = var_ann (ptr); v_ann = var_ann (ptr);
/* If we don't know what this pointer points to then we have
to make sure to not prune virtual operands based on offset
and size. */
if (v_ann->symbol_mem_tag) if (v_ann->symbol_mem_tag)
add_virtual_operand (v_ann->symbol_mem_tag, s_ann, flags, add_virtual_operand (v_ann->symbol_mem_tag, s_ann, flags,
full_ref, offset, size, false); full_ref, 0, -1, false);
/* Aliasing information is missing; mark statement as /* Aliasing information is missing; mark statement as
volatile so we won't optimize it out too actively. */ volatile so we won't optimize it out too actively. */
......
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