From: Richard Guenther Date: Mon, 16 Aug 2010 09:55:54 +0000 (+0000) Subject: tree-cfg.c (verify_types_in_gimple_reference): Verify TARGET_MEM_REF a bit. X-Git-Tag: releases/gcc-4.6.0~4985 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b228e61a98d8bdd1286e536a1f74cdbce50d0ff;p=thirdparty%2Fgcc.git tree-cfg.c (verify_types_in_gimple_reference): Verify TARGET_MEM_REF a bit. 2010-08-16 Richard Guenther * 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. From-SVN: r163278 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1098e53dcb26..57df2abca9c6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,41 @@ +2010-08-16 Richard Guenther + + * 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. + 2010-08-15 Uros Bizjak * doc/invoke.texi (-fomit-frame-pointer): Document that starting diff --git a/gcc/alias.c b/gcc/alias.c index 499354bbf35d..6defc79d7a04 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -619,10 +619,6 @@ get_alias_set (tree t) if (set != -1) return set; - /* Retrieve the original memory reference if needed. */ - if (TREE_CODE (t) == TARGET_MEM_REF) - t = TMR_ORIGINAL (t); - /* Get the base object of the reference. */ inner = t; while (handled_component_p (inner)) @@ -643,6 +639,8 @@ get_alias_set (tree t) if (set != -1) return set; } + else if (TREE_CODE (inner) == TARGET_MEM_REF) + return get_deref_alias_set (TMR_OFFSET (inner)); else if (TREE_CODE (inner) == MEM_REF) { set = get_deref_alias_set_1 (TREE_OPERAND (inner, 1)); diff --git a/gcc/expr.c b/gcc/expr.c index 116c8df0f8ef..2cfb5b379ff8 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8658,25 +8658,13 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, { addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp)); struct mem_address addr; - tree base; get_address_description (exp, &addr); op0 = addr_for_mem_ref (&addr, as, true); op0 = memory_address_addr_space (mode, op0, as); temp = gen_rtx_MEM (mode, op0); - set_mem_attributes (temp, TMR_ORIGINAL (exp), 0); + set_mem_attributes (temp, exp, 0); set_mem_addr_space (temp, as); - base = get_base_address (TMR_ORIGINAL (exp)); - if (base - && (INDIRECT_REF_P (base) || TREE_CODE (base) == MEM_REF) - && TMR_BASE (exp) - && TREE_CODE (TMR_BASE (exp)) == SSA_NAME - && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (exp)))) - { - set_mem_expr (temp, build1 (INDIRECT_REF, - TREE_TYPE (exp), TMR_BASE (exp))); - set_mem_offset (temp, NULL_RTX); - } } return temp; diff --git a/gcc/gimple.c b/gcc/gimple.c index e3de8344c56f..64d338ccfacd 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -3009,6 +3009,9 @@ get_base_address (tree t) if (TREE_CODE (t) == MEM_REF && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) t = TREE_OPERAND (TREE_OPERAND (t, 0), 0); + else if (TREE_CODE (t) == TARGET_MEM_REF + && TMR_SYMBOL (t)) + t = TMR_SYMBOL (t); if (SSA_VAR_P (t) || TREE_CODE (t) == STRING_CST diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 413d7a9fb978..34f982d8878c 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2988,6 +2988,17 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue) return true; } } + else if (TREE_CODE (expr) == TARGET_MEM_REF) + { + if (!TMR_OFFSET (expr) + || TREE_CODE (TMR_OFFSET (expr)) != INTEGER_CST + || !POINTER_TYPE_P (TREE_TYPE (TMR_OFFSET (expr)))) + { + error ("Invalid offset operand in TARGET_MEM_REF."); + debug_generic_stmt (expr); + return true; + } + } return ((require_lvalue || !is_gimple_min_invariant (expr)) && verify_types_in_gimple_min_lval (expr)); diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 461e2cf22772..10fd41e5e0fa 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -878,6 +878,37 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, } goto done; + case TARGET_MEM_REF: + /* Hand back the decl for MEM[&decl, off]. */ + if (TMR_SYMBOL (exp)) + { + /* Via the variable index we can reach the whole object. */ + if (TMR_INDEX (exp)) + { + exp = TMR_SYMBOL (exp); + bit_offset = 0; + maxsize = -1; + goto done; + } + if (integer_zerop (TMR_OFFSET (exp))) + exp = TMR_SYMBOL (exp); + else + { + double_int off = mem_ref_offset (exp); + off = double_int_lshift (off, + BITS_PER_UNIT == 8 + ? 3 : exact_log2 (BITS_PER_UNIT), + HOST_BITS_PER_DOUBLE_INT, true); + off = double_int_add (off, shwi_to_double_int (bit_offset)); + if (double_int_fits_in_shwi_p (off)) + { + bit_offset = double_int_to_shwi (off); + exp = TMR_SYMBOL (exp); + } + } + } + goto done; + default: goto done; } @@ -1010,6 +1041,22 @@ get_addr_base_and_unit_offset (tree exp, HOST_WIDE_INT *poffset) } goto done; + case TARGET_MEM_REF: + /* Hand back the decl for MEM[&decl, off]. */ + if (TMR_SYMBOL (exp)) + { + if (TMR_SYMBOL (exp)) + return NULL_TREE; + if (!integer_zerop (TMR_OFFSET (exp))) + { + double_int off = mem_ref_offset (exp); + gcc_assert (off.high == -1 || off.high == 0); + byte_offset += double_int_to_shwi (off); + } + exp = TMR_SYMBOL (exp); + } + goto done; + default: goto done; } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index ab501d5e0a63..d5b5360014ce 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2405,11 +2405,10 @@ tree_could_trap_p (tree expr) switch (code) { case TARGET_MEM_REF: - /* For TARGET_MEM_REFs use the information based on the original - reference. */ - expr = TMR_ORIGINAL (expr); - code = TREE_CODE (expr); - goto restart; + if (TMR_SYMBOL (expr) + && !TMR_INDEX (expr)) + return false; + return !TREE_THIS_NOTRAP (expr); case COMPONENT_REF: case REALPART_EXPR: diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 4c03fbed332e..1dc612151bb7 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -893,13 +893,6 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, dump_generic_node (buffer, tmp, spc, flags, false); } pp_string (buffer, "]"); - if (flags & TDF_DETAILS) - { - pp_string (buffer, "{"); - dump_generic_node (buffer, TMR_ORIGINAL (node), spc, flags, - false); - pp_string (buffer, "}"); - } } break; diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index 474a7986a232..305a0135e552 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -198,7 +198,10 @@ addr_for_mem_ref (struct mem_address *addr, addr_space_t as, st = NULL_RTX; if (addr->offset && !integer_zerop (addr->offset)) - off = immed_double_int_const (tree_to_double_int (addr->offset), address_mode); + off = immed_double_int_const + (double_int_sext (tree_to_double_int (addr->offset), + TYPE_PRECISION (TREE_TYPE (addr->offset))), + address_mode); else off = NULL_RTX; @@ -346,8 +349,10 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr) if (addr->step && integer_onep (addr->step)) addr->step = NULL_TREE; - if (addr->offset && integer_zerop (addr->offset)) - addr->offset = NULL_TREE; + if (addr->offset) + addr->offset = fold_convert (alias_ptr_type, addr->offset); + else + addr->offset = build_int_cst (alias_ptr_type, 0); /* If possible use a plain MEM_REF instead of a TARGET_MEM_REF. */ if (alias_ptr_type @@ -355,22 +360,18 @@ create_mem_ref_raw (tree type, tree alias_ptr_type, struct mem_address *addr) && !addr->step && (!addr->base || POINTER_TYPE_P (TREE_TYPE (addr->base)))) { - tree base, offset; + tree base; gcc_assert (!addr->symbol ^ !addr->base); if (addr->symbol) base = build_fold_addr_expr (addr->symbol); else base = addr->base; - if (addr->offset) - offset = fold_convert (alias_ptr_type, addr->offset); - else - offset = build_int_cst (alias_ptr_type, 0); - return fold_build2 (MEM_REF, type, base, offset); + return fold_build2 (MEM_REF, type, base, addr->offset); } - return build6 (TARGET_MEM_REF, type, + return build5 (TARGET_MEM_REF, type, addr->symbol, addr->base, addr->index, - addr->step, addr->offset, NULL); + addr->step, addr->offset); } /* Returns true if OBJ is an object whose address is a link time constant. */ @@ -820,7 +821,6 @@ void copy_mem_ref_info (tree to, tree from) { /* And the info about the original reference. */ - TMR_ORIGINAL (to) = TMR_ORIGINAL (from); TREE_SIDE_EFFECTS (to) = TREE_SIDE_EFFECTS (from); TREE_THIS_VOLATILE (to) = TREE_THIS_VOLATILE (from); } @@ -839,13 +839,9 @@ maybe_fold_tmr (tree ref) if (addr.base && TREE_CODE (addr.base) == INTEGER_CST) { - if (addr.offset) - addr.offset = fold_binary_to_constant (PLUS_EXPR, sizetype, - addr.offset, - fold_convert (sizetype, addr.base)); - else - addr.offset = addr.base; - + addr.offset = fold_binary_to_constant (PLUS_EXPR, + TREE_TYPE (addr.offset), + addr.offset, addr.base); addr.base = NULL_TREE; changed = true; } @@ -860,14 +856,9 @@ maybe_fold_tmr (tree ref) addr.step = NULL_TREE; } - if (addr.offset) - { - addr.offset = fold_binary_to_constant (PLUS_EXPR, sizetype, - addr.offset, off); - } - else - addr.offset = off; - + addr.offset = fold_binary_to_constant (PLUS_EXPR, + TREE_TYPE (addr.offset), + addr.offset, off); addr.index = NULL_TREE; changed = true; } @@ -875,7 +866,7 @@ maybe_fold_tmr (tree ref) if (!changed) return NULL_TREE; - ret = create_mem_ref_raw (TREE_TYPE (ref), NULL_TREE, &addr); + ret = create_mem_ref_raw (TREE_TYPE (ref), TREE_TYPE (addr.offset), &addr); if (!ret) return NULL_TREE; diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index eddb9b987c30..849c25004e6d 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, diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index c940d413de8c..f0c3ca9f6d77 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5880,44 +5880,6 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, } } -/* Replaces ssa name in index IDX by its basic variable. Callback for - for_each_index. */ - -static bool -idx_remove_ssa_names (tree base, tree *idx, - void *data ATTRIBUTE_UNUSED) -{ - tree *op; - - if (TREE_CODE (*idx) == SSA_NAME) - *idx = SSA_NAME_VAR (*idx); - - if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF) - { - op = &TREE_OPERAND (base, 2); - if (*op - && TREE_CODE (*op) == SSA_NAME) - *op = SSA_NAME_VAR (*op); - op = &TREE_OPERAND (base, 3); - if (*op - && TREE_CODE (*op) == SSA_NAME) - *op = SSA_NAME_VAR (*op); - } - - return true; -} - -/* Unshares REF and replaces ssa names inside it by their basic variables. */ - -static tree -unshare_and_remove_ssa_names (tree ref) -{ - ref = unshare_expr (ref); - for_each_index (&ref, idx_remove_ssa_names, NULL); - - return ref; -} - /* Copies the reference information from OLD_REF to NEW_REF. */ static void @@ -5925,12 +5887,6 @@ copy_ref_info (tree new_ref, tree old_ref) { tree new_ptr_base = NULL_TREE; - if (TREE_CODE (old_ref) == TARGET_MEM_REF - && TREE_CODE (new_ref) == TARGET_MEM_REF) - TMR_ORIGINAL (new_ref) = TMR_ORIGINAL (old_ref); - else if (TREE_CODE (new_ref) == TARGET_MEM_REF) - TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); - TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 88ebcf645bc2..e17aefc2eee9 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2773,8 +2773,6 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, break; case TARGET_MEM_REF: { - vn_reference_op_t nextop = VEC_index (vn_reference_op_s, ref->operands, - *operand); pre_expr op0expr; tree genop0 = NULL_TREE; tree baseop = create_component_ref_by_pieces_1 (block, ref, operand, @@ -2790,15 +2788,13 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, return NULL_TREE; } if (DECL_P (baseop)) - return build6 (TARGET_MEM_REF, currop->type, + return build5 (TARGET_MEM_REF, currop->type, baseop, NULL_TREE, - genop0, currop->op1, currop->op2, - unshare_expr (nextop->op1)); + genop0, currop->op1, currop->op2); else - return build6 (TARGET_MEM_REF, currop->type, + return build5 (TARGET_MEM_REF, currop->type, NULL_TREE, baseop, - genop0, currop->op1, currop->op2, - unshare_expr (nextop->op1)); + genop0, currop->op1, currop->op2); } break; case ADDR_EXPR: diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index cfd22dbedba1..21662d65713e 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -595,7 +595,6 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) temp.type = NULL_TREE; temp.opcode = TREE_CODE (base); temp.op0 = base; - temp.op1 = TMR_ORIGINAL (ref); temp.off = -1; VEC_safe_push (vn_reference_op_s, heap, *result, &temp); return; diff --git a/gcc/tree.c b/gcc/tree.c index 391d0040a7e8..c4092ab5dee5 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3906,12 +3906,12 @@ build_simple_mem_ref_loc (location_t loc, tree ptr) return tem; } -/* Return the constant offset of a MEM_REF tree T. */ +/* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T. */ double_int mem_ref_offset (const_tree t) { - tree toff = TREE_OPERAND (t, 1); + tree toff = TREE_CODE (t) == MEM_REF ? TREE_OPERAND (t, 1) : TMR_OFFSET (t); return double_int_sext (tree_to_double_int (toff), TYPE_PRECISION (TREE_TYPE (toff))); } @@ -3928,8 +3928,9 @@ reference_alias_ptr_type (const_tree t) base = TREE_OPERAND (base, 0); if (TREE_CODE (base) == MEM_REF) return TREE_TYPE (TREE_OPERAND (base, 1)); - else if (TREE_CODE (base) == TARGET_MEM_REF - || TREE_CODE (base) == MISALIGNED_INDIRECT_REF) + else if (TREE_CODE (base) == TARGET_MEM_REF) + return TREE_TYPE (TMR_OFFSET (base)); + else if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF) return NULL_TREE; else return build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (base))); diff --git a/gcc/tree.def b/gcc/tree.def index 493c75e79af7..c71a8751709a 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -958,13 +958,13 @@ DEFTREECODE (REALIGN_LOAD_EXPR, "realign_load", tcc_expression, 3) SYMBOL + BASE + STEP * INDEX + OFFSET. Only variations and values valid on the target are allowed. - The type of STEP, INDEX and OFFSET is sizetype. The type of BASE is + The type of STEP and INDEX is sizetype. The type of BASE is sizetype or a pointer type (if SYMBOL is NULL). - The sixth argument is the reference to the original memory access, which - is preserved for the purpose of alias analysis. */ + The type of OFFSET is a pointer type and determines TBAA the same as + the constant offset operand in MEM_REF. */ -DEFTREECODE (TARGET_MEM_REF, "target_mem_ref", tcc_reference, 6) +DEFTREECODE (TARGET_MEM_REF, "target_mem_ref", tcc_reference, 5) /* Memory addressing. Operands are a pointer and a tree constant integer byte offset of the pointer type that when dereferenced yields the diff --git a/gcc/tree.h b/gcc/tree.h index 9a3c93d356f6..d16a475a3533 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1622,7 +1622,6 @@ extern void protected_set_expr_location (tree, location_t); #define TMR_INDEX(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 2)) #define TMR_STEP(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 3)) #define TMR_OFFSET(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 4)) -#define TMR_ORIGINAL(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 5)) /* The operands of a BIND_EXPR. */ #define BIND_EXPR_VARS(NODE) (TREE_OPERAND (BIND_EXPR_CHECK (NODE), 0))