summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-operands.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-27 11:10:09 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-27 11:10:09 +0000
commitf0e6e3c17006ce3e12dffc4d6d2fb51d2dd0fd05 (patch)
treed85cb716334c8b33922dc03cb2aa35570be10c3b /gcc/tree-ssa-operands.c
parentcff3e347c3f5af4709ff8b9ecdd31c610860bc40 (diff)
downloadgcc-f0e6e3c17006ce3e12dffc4d6d2fb51d2dd0fd05.tar.gz
2007-10-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/33870 * tree-ssa-operands.c (add_vars_for_offset): Reduce code duplication. Remove redundant call to access_can_touch_variable. (add_vars_for_bitmap): New helper for recursing over MPT contents. (add_virtual_operand): Use it. * gcc.dg/tree-ssa/alias-15.c: New testcase. * gcc.c-torture/execute/pr33870.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129675 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-operands.c')
-rw-r--r--gcc/tree-ssa-operands.c108
1 files changed, 47 insertions, 61 deletions
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 3a944efa0b3..206c04bd484 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -1419,55 +1419,57 @@ add_vars_for_offset (tree full_ref, tree var, HOST_WIDE_INT offset,
}
else if (TREE_CODE (var) == STRUCT_FIELD_TAG)
{
- if (size == -1)
+ bool added = false;
+ subvar_t sv = get_subvars_for_var (SFT_PARENT_VAR (var));
+ for (; sv; sv = sv->next)
{
- bool added = false;
- subvar_t sv = get_subvars_for_var (SFT_PARENT_VAR (var));
- for (; sv; sv = sv->next)
- {
- if (overlap_subvar (SFT_OFFSET (var) + offset, size,
- sv->var, NULL)
- && access_can_touch_variable (full_ref, sv->var,
- offset, size))
- {
- added = true;
- if (is_def)
- append_vdef (sv->var);
- else
- append_vuse (sv->var);
- }
- }
- return added;
- }
- else
- {
- bool added = false;
- subvar_t sv = get_subvars_for_var (SFT_PARENT_VAR (var));
- for (; sv; sv = sv->next)
+ /* Once we hit the end of the parts that could touch,
+ stop looking. */
+ if (size != -1
+ && SFT_OFFSET (var) + offset + size <= SFT_OFFSET (sv->var))
+ break;
+ if (overlap_subvar (SFT_OFFSET (var) + offset, size, sv->var, NULL))
{
- /* Once we hit the end of the parts that could touch,
- stop looking. */
- if (SFT_OFFSET (var) + offset + size <= SFT_OFFSET (sv->var))
- break;
- if (overlap_subvar (SFT_OFFSET (var) + offset, size,
- sv->var, NULL)
- && access_can_touch_variable (full_ref, sv->var, offset,
- size))
- {
- added = true;
- if (is_def)
- append_vdef (sv->var);
- else
- append_vuse (sv->var);
- }
+ added = true;
+ if (is_def)
+ append_vdef (sv->var);
+ else
+ append_vuse (sv->var);
}
- return added;
}
+ return added;
}
return false;
}
+/* Add all aliases from ALIASES as virtual operands for the access
+ FULL_REF at OFFSET and size SIZE. IS_CALL_SITE is true if the
+ stmt of the reference is a call. IS_DEF is true if we should add
+ VDEF virtual operands, otherwise we'll add VUSEs. *NONE_ADDED
+ is set to false once the first virtual operand was added. */
+
+static void
+add_vars_for_bitmap (bitmap aliases, tree full_ref,
+ HOST_WIDE_INT offset, HOST_WIDE_INT size,
+ bool is_call_site, bool is_def, bool *none_added)
+{
+ bitmap_iterator bi;
+ unsigned int i;
+
+ EXECUTE_IF_SET_IN_BITMAP (aliases, 0, i, bi)
+ {
+ tree al = referenced_var (i);
+
+ if (TREE_CODE (al) == MEMORY_PARTITION_TAG)
+ add_vars_for_bitmap (MPT_SYMBOLS (al), full_ref,
+ offset, size, is_call_site, is_def, none_added);
+ else
+ *none_added &= !add_vars_for_offset (full_ref, al, offset, size,
+ is_call_site, is_def);
+ }
+}
+
/* Add VAR to the virtual operands array. FLAGS is as in
get_expr_operands. FULL_REF is a tree that contains the entire
pointer dereference expression, if available, or NULL otherwise.
@@ -1530,24 +1532,17 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
}
else
{
- bitmap_iterator bi;
- unsigned int i;
- tree al;
+ bool none_added = true;
/* The variable is aliased. Add its aliases to the virtual
operands. */
gcc_assert (!bitmap_empty_p (aliases));
-
+
+ add_vars_for_bitmap (aliases, full_ref, offset, size,
+ is_call_site, flags & opf_def, &none_added);
+
if (flags & opf_def)
{
- bool none_added = true;
- EXECUTE_IF_SET_IN_BITMAP (aliases, 0, i, bi)
- {
- al = referenced_var (i);
- none_added &= !add_vars_for_offset (full_ref, al, offset, size,
- is_call_site, true);
- }
-
/* If the variable is also an alias tag, add a virtual
operand for it, otherwise we will miss representing
references to the members of the variable's alias set.
@@ -1566,15 +1561,6 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags,
}
else
{
- bool none_added = true;
- EXECUTE_IF_SET_IN_BITMAP (aliases, 0, i, bi)
- {
- al = referenced_var (i);
- none_added &= !add_vars_for_offset (full_ref, al, offset, size,
- is_call_site, false);
-
- }
-
/* Even if no aliases have been added, we still need to
establish def-use and use-def chains, lest
transformations think that this is not a memory