diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-16 09:55:54 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-16 09:55:54 +0000 |
commit | 9a14ba4fd861436294514c3008d03f1f77de058a (patch) | |
tree | 4edd6a80f5f5a0a0c23401f9e90a871371fc79be /gcc/tree-ssa-alias.c | |
parent | 30f7a5ed3b1d1e529a563db9e8d03507c8c59e0a (diff) | |
download | gcc-9a14ba4fd861436294514c3008d03f1f77de058a.tar.gz |
2010-08-16 Richard Guenther <rguenther@suse.de>
* tree-cfg.c (verify_types_in_gimple_reference): Verify
TARGET_MEM_REF a bit.
* tree-ssa-address.c (addr_for_mem_ref): Adjust.
(create_mem_ref_raw): Always create TMR_OFFSET, store the
alias pointer type via it.
(copy_mem_ref_info): Adjust.
(maybe_fold_tmr): Likewise.
* tree.c (mem_ref_offset): Also handle TARGET_MEM_REF.
(reference_alias_ptr_type): Likewise.
* tree.def (TARGET_MEM_REF): Remove TMR_ORIGINAL operand,
adjust documentation of TMR_OFFSET operand.
* alias.c (get_alias_set): Do not look at TMR_ORIGINAL but
use the alias pointer type.
* expr.c (expand_expr_real_1): Do not use TMR_ORIGINAL to
initialize mem attrs but the TMR itself.
* tree-eh.c (tree_could_trap_p): Handle TARGET_MEM_REF
similar to MEM_REF.
* tree-pretty-print.c (dump_generic_node): Do not dump TMR_ORIGINAL.
* tree-ssa-loop-ivopts.c (idx_remove_ssa_names): Remove.
(unshare_and_remove_ssa_names): Likewise.
(copy_ref_info): Adjust.
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Simplify
TARGET_MEM_REF case.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Do not look
at TMR_ORIGINAL.
* tree.h (TMR_ORIGINAL): Remove.
* gimple.c (get_base_address): For TARGET_MEM_REF with a
symbol return that.
* tree-dfa.c (get_ref_base_and_extent): Handle TARGET_MEM_REF
with a symbol.
(get_addr_base_and_unit_offset): Likewise.
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Handle
TARGET_MEM_REFs.
(indirect_ref_may_alias_decl_p): Likewise.
(refs_may_alias_p_1): Do not bail out for TARGET_MEM_REFs.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163278 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 96 |
1 files changed, 75 insertions, 21 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index eddb9b987c3..849c25004e6 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -666,13 +666,24 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, alias_set_type ref2_alias_set, alias_set_type base2_alias_set, bool tbaa_p) { - tree ptr1 = TREE_OPERAND (base1, 0); + tree ptr1; tree ptrtype1; HOST_WIDE_INT offset1p = offset1, offset2p = offset2; + if (TREE_CODE (base1) == TARGET_MEM_REF) + { + if (!TMR_BASE (base1) + || !POINTER_TYPE_P (TMR_BASE (base1))) + return true; + ptr1 = TMR_BASE (base1); + } + else + ptr1 = TREE_OPERAND (base1, 0); + /* The offset embedded in MEM_REFs can be negative. Bias them so that the resulting offset adjustment is positive. */ - if (TREE_CODE (base1) == MEM_REF) + if (TREE_CODE (base1) == MEM_REF + || TREE_CODE (base1) == TARGET_MEM_REF) { double_int moff = mem_ref_offset (base1); moff = double_int_lshift (moff, @@ -690,7 +701,8 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, (the pointer base cannot validly point to an offset less than zero of the variable). They also cannot alias if the pointer may not point to the decl. */ - if (!ranges_overlap_p (MAX (0, offset1p), -1, offset2p, max_size2)) + if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1)) + && !ranges_overlap_p (MAX (0, offset1p), -1, offset2p, max_size2)) return false; if (!ptr_deref_may_alias_decl_p (ptr1, base2)) return false; @@ -701,6 +713,8 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, if (TREE_CODE (base1) == MEM_REF) ptrtype1 = TREE_TYPE (TREE_OPERAND (base1, 1)); + else if (TREE_CODE (base1) == TARGET_MEM_REF) + ptrtype1 = TREE_TYPE (TMR_OFFSET (base1)); else ptrtype1 = TREE_TYPE (ptr1); @@ -719,8 +733,9 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, is relative to the start of the type which we ensure by comparing rvalue and access type and disregarding the constant pointer offset. */ - if ((TREE_CODE (base1) != MEM_REF - || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1) + if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1)) + && (TREE_CODE (base1) != MEM_REF + || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1) && same_type_for_tbaa (TREE_TYPE (ptrtype1), TREE_TYPE (base2)) == 1) return ranges_overlap_p (offset1, max_size1, offset2, max_size2); @@ -757,6 +772,7 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, if (ref1 && ref2 && handled_component_p (ref1) && handled_component_p (ref2) + && TREE_CODE (base1) != TARGET_MEM_REF && (TREE_CODE (base1) != MEM_REF || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1)) return aliasing_component_refs_p (ref1, TREE_TYPE (ptrtype1), @@ -786,19 +802,51 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, alias_set_type ref2_alias_set, alias_set_type base2_alias_set, bool tbaa_p) { - tree ptr1 = TREE_OPERAND (base1, 0); - tree ptr2 = TREE_OPERAND (base2, 0); + tree ptr1; + tree ptr2; tree ptrtype1, ptrtype2; + if (TREE_CODE (base1) == TARGET_MEM_REF) + { + if (!TMR_BASE (base1) + || !POINTER_TYPE_P (TMR_BASE (base1))) + return true; + ptr1 = TMR_BASE (base1); + } + else + ptr1 = TREE_OPERAND (base1, 0); + + if (TREE_CODE (base2) == TARGET_MEM_REF) + { + if (!TMR_BASE (base2) + || !POINTER_TYPE_P (TMR_BASE (base2))) + return true; + ptr2 = TMR_BASE (base2); + } + else + ptr2 = TREE_OPERAND (base2, 0); + /* If both bases are based on pointers they cannot alias if they may not point to the same memory object or if they point to the same object and the accesses do not overlap. */ if ((!cfun || gimple_in_ssa_p (cfun)) - && operand_equal_p (ptr1, ptr2, 0)) + && operand_equal_p (ptr1, ptr2, 0) + && (((TREE_CODE (base1) != TARGET_MEM_REF + || !TMR_INDEX (base1)) + && (TREE_CODE (base2) != TARGET_MEM_REF + || !TMR_INDEX (base2))) + || (TREE_CODE (base1) == TARGET_MEM_REF + && TREE_CODE (base2) == TARGET_MEM_REF + && (TMR_STEP (base1) == TMR_STEP (base2) + || (TMR_STEP (base1) && TMR_STEP (base2) + && operand_equal_p (TMR_STEP (base1), + TMR_STEP (base2), 0))) + && operand_equal_p (TMR_INDEX (base1), TMR_INDEX (base2), 0)))) { /* The offset embedded in MEM_REFs can be negative. Bias them so that the resulting offset adjustment is positive. */ - if (TREE_CODE (base1) == MEM_REF) + if (TREE_CODE (base1) == MEM_REF + || TREE_CODE (base1) == TARGET_MEM_REF) { double_int moff = mem_ref_offset (base1); moff = double_int_lshift (moff, @@ -810,7 +858,8 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, else offset1 += moff.low; } - if (TREE_CODE (base2) == MEM_REF) + if (TREE_CODE (base2) == MEM_REF + || TREE_CODE (base2) == TARGET_MEM_REF) { double_int moff = mem_ref_offset (base2); moff = double_int_lshift (moff, @@ -833,10 +882,14 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, if (TREE_CODE (base1) == MEM_REF) ptrtype1 = TREE_TYPE (TREE_OPERAND (base1, 1)); + else if (TREE_CODE (base1) == TARGET_MEM_REF) + ptrtype1 = TREE_TYPE (TMR_OFFSET (base1)); else ptrtype1 = TREE_TYPE (ptr1); if (TREE_CODE (base2) == MEM_REF) ptrtype2 = TREE_TYPE (TREE_OPERAND (base2, 1)); + else if (TREE_CODE (base2) == TARGET_MEM_REF) + ptrtype2 = TREE_TYPE (TMR_OFFSET (base2)); else ptrtype2 = TREE_TYPE (ptr2); @@ -853,8 +906,10 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, /* If both references are through the same type, they do not alias if the accesses do not overlap. This does extra disambiguation for mixed/pointer accesses but requires strict aliasing. */ - if ((TREE_CODE (base1) != MEM_REF - || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1) + if ((TREE_CODE (base1) != TARGET_MEM_REF || !TMR_INDEX (base1)) + && (TREE_CODE (base2) != TARGET_MEM_REF || !TMR_INDEX (base2)) + && (TREE_CODE (base1) != MEM_REF + || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1) && (TREE_CODE (base2) != MEM_REF || same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1) && same_type_for_tbaa (TREE_TYPE (ptrtype1), @@ -870,6 +925,8 @@ indirect_refs_may_alias_p (tree ref1 ATTRIBUTE_UNUSED, tree base1, if (ref1 && ref2 && handled_component_p (ref1) && handled_component_p (ref2) + && TREE_CODE (base1) != TARGET_MEM_REF + && TREE_CODE (base2) != TARGET_MEM_REF && (TREE_CODE (base1) != MEM_REF || same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) == 1) && (TREE_CODE (base2) != MEM_REF @@ -947,8 +1004,12 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p) return decl_refs_may_alias_p (base1, offset1, max_size1, base2, offset2, max_size2); - ind1_p = INDIRECT_REF_P (base1) || (TREE_CODE (base1) == MEM_REF); - ind2_p = INDIRECT_REF_P (base2) || (TREE_CODE (base2) == MEM_REF); + ind1_p = (INDIRECT_REF_P (base1) + || (TREE_CODE (base1) == MEM_REF) + || (TREE_CODE (base1) == TARGET_MEM_REF)); + ind2_p = (INDIRECT_REF_P (base2) + || (TREE_CODE (base2) == MEM_REF) + || (TREE_CODE (base2) == TARGET_MEM_REF)); /* Canonicalize the pointer-vs-decl case. */ if (ind1_p && var2_p) @@ -973,13 +1034,6 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p) ao_ref_alias_set (ref2))) return false; - /* If one reference is a TARGET_MEM_REF weird things are allowed. Still - TBAA disambiguation based on the access type is possible, so bail - out only after that check. */ - if ((ref1->ref && TREE_CODE (ref1->ref) == TARGET_MEM_REF) - || (ref2->ref && TREE_CODE (ref2->ref) == TARGET_MEM_REF)) - return true; - /* Dispatch to the pointer-vs-decl or pointer-vs-pointer disambiguators. */ if (var1_p && ind2_p) return indirect_ref_may_alias_decl_p (ref2->ref, base2, |