[patch, 4.1.2, 4.2.1, 4.3] Fix a bug in pointer dependency test
Ira Rosen
IRAR@il.ibm.com
Mon Jan 15 10:49:00 GMT 2007
As pointed out by Daniel, there is a bug in pointers' dependency test in
data-refs analysis. Currently, only tags are compared, while two different
tags can have common symbols in their may-alias sets. Therefore, in the
case of different tags, may-alias sets must be examined too.
This patch fixes this problem using pointer-sets, as suggested by Diego.
(We can't compare vops, since we don't have the original statements at this
stage).
Bootstrapped and tested on ppc-linux.
O.K. for mainline (and 4.1.2 and 4.2.1) ?
Thanks,
Ira
ChangeLog entry:
* tree-ssa-alias.c (may_aliases_intersect): New function.
* tree-data-ref.c (ptr_ptr_may_alias_p): Call may_aliases_intersect
for different tags.
* tree-flow.h (may_aliases_intersect): Add function declaration.
The patch:
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c (revision 120765)
+++ tree-ssa-alias.c (working copy)
@@ -2609,6 +2609,35 @@ is_aliased_with (tree tag, tree sym)
return false;
}
+/* Given two tags return TRUE if their may-alias sets intersect. */
+
+bool
+may_aliases_intersect (tree tag1, tree tag2)
+{
+ struct pointer_set_t *set1 = pointer_set_create ();
+ unsigned i;
+ VEC(tree,gc) *may_aliases1 = may_aliases (tag1);
+ VEC(tree,gc) *may_aliases2 = may_aliases (tag2);
+ tree sym;
+
+ /* Insert all the symbols from the first may-alias set into the
+ pointer-set. */
+ for (i = 0; VEC_iterate (tree, may_aliases1, i, sym); i++)
+ pointer_set_insert (set1, sym);
+
+ /* Go through the second may-alias set and check if it contains symbols
that
+ are common with the first set. */
+ for (i = 0; VEC_iterate (tree, may_aliases2, i, sym); i++)
+ if (pointer_set_contains (set1, sym))
+ {
+ pointer_set_destroy (set1);
+ return true;
+ }
+
+ pointer_set_destroy (set1);
+ return false;
+}
+
/* The following is based on code in add_stmt_operand to ensure that the
same defs/uses/vdefs/vuses will be found after replacing a reference
to var (or ARRAY_REF to var) with an INDIRECT_REF to ptr whose value
Index: tree-data-ref.c
===================================================================
--- tree-data-ref.c (revision 120765)
+++ tree-data-ref.c (working copy)
@@ -192,7 +192,12 @@ ptr_ptr_may_alias_p (tree ptr_a, tree pt
if (!tag_b)
return false;
}
- *aliased = (tag_a == tag_b);
+
+ if (tag_a == tag_b)
+ *aliased = true;
+ else
+ *aliased = may_aliases_intersect (tag_a, tag_b);
+
return true;
}
Index: tree-flow.h
===================================================================
--- tree-flow.h (revision 120765)
+++ tree-flow.h (working copy)
@@ -729,6 +729,7 @@ extern void dump_points_to_info_for (FIL
extern void debug_points_to_info_for (tree);
extern bool may_be_aliased (tree);
extern bool is_aliased_with (tree, tree);
+extern bool may_aliases_intersect (tree, tree);
extern struct ptr_info_def *get_ptr_info (tree);
extern void new_type_alias (tree, tree, tree);
extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *,
bool *);
New test case:
(See attached file: vect-106.c.txt)
::ADDPATCH SSA:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vect-106.c.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070115/30dbda61/attachment.txt>
More information about the Gcc-patches
mailing list