This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Kill TMR_ORIGINAL, use TMR_OFFSET to store TBAA alias info
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Aug 2010 17:29:50 +0200 (CEST)
- Subject: [PATCH] Kill TMR_ORIGINAL, use TMR_OFFSET to store TBAA alias info
This is step 1 to morphing TARGET_MEM_REF into a MEM_REF with variable
offset. It uses TMR_OFFSET to store TBAA info like we do for the
offset operand in MEM_REFs. This allows us to drop TMR_ORIGINAL which
we kept solely for the purpose of preserving alias info.
Step 2 will be unifying TMR_BASE and TMR_SYMBOL to form an address
operand similar to that of MEM_REF and forcing TMR_INDEX and TMR_STEP
to be non-NULL.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Any comments?
Thanks,
Richard.
2010-08-11 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.
Index: trunk/gcc/tree-cfg.c
===================================================================
*** trunk.orig/gcc/tree-cfg.c 2010-08-11 12:43:22.000000000 +0200
--- trunk/gcc/tree-cfg.c 2010-08-11 13:00:04.000000000 +0200
*************** verify_types_in_gimple_reference (tree e
*** 3057,3062 ****
--- 3057,3073 ----
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));
Index: trunk/gcc/tree-ssa-address.c
===================================================================
*** trunk.orig/gcc/tree-ssa-address.c 2010-08-11 12:43:22.000000000 +0200
--- trunk/gcc/tree-ssa-address.c 2010-08-11 13:49:53.000000000 +0200
*************** addr_for_mem_ref (struct mem_address *ad
*** 198,204 ****
st = NULL_RTX;
if (addr->offset && !integer_zerop (addr->offset))
! off = immed_double_int_const (tree_to_double_int (addr->offset), address_mode);
else
off = NULL_RTX;
--- 198,207 ----
st = NULL_RTX;
if (addr->offset && !integer_zerop (addr->offset))
! 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;
*************** create_mem_ref_raw (tree type, tree alia
*** 346,353 ****
if (addr->step && integer_onep (addr->step))
addr->step = NULL_TREE;
! if (addr->offset && integer_zerop (addr->offset))
! addr->offset = NULL_TREE;
/* If possible use a plain MEM_REF instead of a TARGET_MEM_REF. */
if (alias_ptr_type
--- 349,358 ----
if (addr->step && integer_onep (addr->step))
addr->step = 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
*************** create_mem_ref_raw (tree type, tree alia
*** 355,376 ****
&& !addr->step
&& (!addr->base || POINTER_TYPE_P (TREE_TYPE (addr->base))))
{
! tree base, offset;
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 build6 (TARGET_MEM_REF, type,
addr->symbol, addr->base, addr->index,
! addr->step, addr->offset, NULL);
}
/* Returns true if OBJ is an object whose address is a link time constant. */
--- 360,377 ----
&& !addr->step
&& (!addr->base || POINTER_TYPE_P (TREE_TYPE (addr->base))))
{
! tree base;
gcc_assert (!addr->symbol ^ !addr->base);
if (addr->symbol)
base = build_fold_addr_expr (addr->symbol);
else
base = addr->base;
! return fold_build2 (MEM_REF, type, base, addr->offset);
}
! return build5 (TARGET_MEM_REF, type,
addr->symbol, addr->base, addr->index,
! addr->step, addr->offset);
}
/* Returns true if OBJ is an object whose address is a link time constant. */
*************** void
*** 820,826 ****
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);
}
--- 821,826 ----
*************** maybe_fold_tmr (tree ref)
*** 839,851 ****
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.base = NULL_TREE;
changed = true;
}
--- 839,847 ----
if (addr.base && TREE_CODE (addr.base) == INTEGER_CST)
{
! addr.offset = fold_binary_to_constant (PLUS_EXPR,
! TREE_TYPE (addr.offset),
! addr.offset, addr.base);
addr.base = NULL_TREE;
changed = true;
}
*************** maybe_fold_tmr (tree ref)
*** 860,873 ****
addr.step = NULL_TREE;
}
! if (addr.offset)
! {
! addr.offset = fold_binary_to_constant (PLUS_EXPR, sizetype,
! addr.offset, off);
! }
! else
! addr.offset = off;
!
addr.index = NULL_TREE;
changed = true;
}
--- 856,864 ----
addr.step = NULL_TREE;
}
! addr.offset = fold_binary_to_constant (PLUS_EXPR,
! TREE_TYPE (addr.offset),
! addr.offset, off);
addr.index = NULL_TREE;
changed = true;
}
*************** maybe_fold_tmr (tree ref)
*** 875,881 ****
if (!changed)
return NULL_TREE;
! ret = create_mem_ref_raw (TREE_TYPE (ref), NULL_TREE, &addr);
if (!ret)
return NULL_TREE;
--- 866,872 ----
if (!changed)
return NULL_TREE;
! ret = create_mem_ref_raw (TREE_TYPE (ref), TREE_TYPE (addr.offset), &addr);
if (!ret)
return NULL_TREE;
Index: trunk/gcc/tree.c
===================================================================
*** trunk.orig/gcc/tree.c 2010-08-11 12:43:22.000000000 +0200
--- trunk/gcc/tree.c 2010-08-11 13:00:04.000000000 +0200
*************** build_simple_mem_ref_loc (location_t loc
*** 3906,3917 ****
return tem;
}
! /* Return the constant offset of a MEM_REF tree T. */
double_int
mem_ref_offset (const_tree t)
{
! tree toff = TREE_OPERAND (t, 1);
return double_int_sext (tree_to_double_int (toff),
TYPE_PRECISION (TREE_TYPE (toff)));
}
--- 3906,3917 ----
return tem;
}
! /* 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_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)));
}
*************** reference_alias_ptr_type (const_tree t)
*** 3928,3935 ****
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)
return NULL_TREE;
else
return build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (base)));
--- 3928,3936 ----
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)
! 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)));
Index: trunk/gcc/tree.def
===================================================================
*** trunk.orig/gcc/tree.def 2010-08-11 12:43:22.000000000 +0200
--- trunk/gcc/tree.def 2010-08-11 13:17:03.000000000 +0200
*************** DEFTREECODE (REALIGN_LOAD_EXPR, "realign
*** 958,970 ****
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
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. */
! DEFTREECODE (TARGET_MEM_REF, "target_mem_ref", tcc_reference, 6)
/* Memory addressing. Operands are a pointer and a tree constant integer
byte offset of the pointer type that when dereferenced yields the
--- 958,970 ----
SYMBOL + BASE + STEP * INDEX + OFFSET. Only variations and values valid on
the target are allowed.
! The type of STEP and INDEX is sizetype. The type of BASE is
sizetype or a pointer type (if SYMBOL is NULL).
! 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, 5)
/* Memory addressing. Operands are a pointer and a tree constant integer
byte offset of the pointer type that when dereferenced yields the
Index: trunk/gcc/alias.c
===================================================================
*** trunk.orig/gcc/alias.c 2010-08-10 11:12:47.000000000 +0200
--- trunk/gcc/alias.c 2010-08-11 15:26:02.000000000 +0200
*************** get_alias_set (tree t)
*** 619,628 ****
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))
--- 619,624 ----
*************** get_alias_set (tree t)
*** 643,648 ****
--- 639,646 ----
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));
Index: trunk/gcc/expr.c
===================================================================
*** trunk.orig/gcc/expr.c 2010-08-06 17:56:44.000000000 +0200
--- trunk/gcc/expr.c 2010-08-11 13:08:52.000000000 +0200
*************** expand_expr_real_1 (tree exp, rtx target
*** 8658,8682 ****
{
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_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;
--- 8658,8670 ----
{
addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
struct mem_address addr;
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, exp, 0);
set_mem_addr_space (temp, as);
}
return temp;
Index: trunk/gcc/tree-eh.c
===================================================================
*** trunk.orig/gcc/tree-eh.c 2010-08-06 17:56:44.000000000 +0200
--- trunk/gcc/tree-eh.c 2010-08-11 14:36:22.000000000 +0200
*************** tree_could_trap_p (tree expr)
*** 2405,2415 ****
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;
case COMPONENT_REF:
case REALPART_EXPR:
--- 2405,2414 ----
switch (code)
{
case TARGET_MEM_REF:
! if (TMR_SYMBOL (expr)
! && !TMR_INDEX (expr))
! return false;
! return !TREE_THIS_NOTRAP (expr);
case COMPONENT_REF:
case REALPART_EXPR:
Index: trunk/gcc/tree-pretty-print.c
===================================================================
*** trunk.orig/gcc/tree-pretty-print.c 2010-08-06 17:56:44.000000000 +0200
--- trunk/gcc/tree-pretty-print.c 2010-08-11 13:15:14.000000000 +0200
*************** dump_generic_node (pretty_printer *buffe
*** 893,905 ****
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;
--- 893,898 ----
Index: trunk/gcc/tree-ssa-loop-ivopts.c
===================================================================
*** trunk.orig/gcc/tree-ssa-loop-ivopts.c 2010-08-11 12:43:22.000000000 +0200
--- trunk/gcc/tree-ssa-loop-ivopts.c 2010-08-11 13:20:59.000000000 +0200
*************** rewrite_use_nonlinear_expr (struct ivopt
*** 5880,5923 ****
}
}
- /* 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
--- 5880,5885 ----
*************** copy_ref_info (tree new_ref, tree old_re
*** 5925,5936 ****
{
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);
--- 5887,5892 ----
Index: trunk/gcc/tree-ssa-pre.c
===================================================================
*** trunk.orig/gcc/tree-ssa-pre.c 2010-08-11 11:05:16.000000000 +0200
--- trunk/gcc/tree-ssa-pre.c 2010-08-11 13:51:57.000000000 +0200
*************** create_component_ref_by_pieces_1 (basic_
*** 2773,2780 ****
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,
--- 2773,2778 ----
*************** create_component_ref_by_pieces_1 (basic_
*** 2790,2804 ****
return NULL_TREE;
}
if (DECL_P (baseop))
! return build6 (TARGET_MEM_REF, currop->type,
baseop, NULL_TREE,
! genop0, currop->op1, currop->op2,
! unshare_expr (nextop->op1));
else
! return build6 (TARGET_MEM_REF, currop->type,
NULL_TREE, baseop,
! genop0, currop->op1, currop->op2,
! unshare_expr (nextop->op1));
}
break;
case ADDR_EXPR:
--- 2788,2800 ----
return NULL_TREE;
}
if (DECL_P (baseop))
! return build5 (TARGET_MEM_REF, currop->type,
baseop, NULL_TREE,
! genop0, currop->op1, currop->op2);
else
! return build5 (TARGET_MEM_REF, currop->type,
NULL_TREE, baseop,
! genop0, currop->op1, currop->op2);
}
break;
case ADDR_EXPR:
Index: trunk/gcc/tree-ssa-sccvn.c
===================================================================
*** trunk.orig/gcc/tree-ssa-sccvn.c 2010-08-06 17:56:44.000000000 +0200
--- trunk/gcc/tree-ssa-sccvn.c 2010-08-11 13:16:26.000000000 +0200
*************** copy_reference_ops_from_ref (tree ref, V
*** 595,601 ****
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;
--- 595,600 ----
Index: trunk/gcc/tree.h
===================================================================
*** trunk.orig/gcc/tree.h 2010-08-11 12:44:30.000000000 +0200
--- trunk/gcc/tree.h 2010-08-11 13:18:38.000000000 +0200
*************** extern void protected_set_expr_location
*** 1622,1628 ****
#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))
--- 1622,1627 ----
Index: trunk/gcc/gimple.c
===================================================================
*** trunk.orig/gcc/gimple.c 2010-07-26 16:02:02.000000000 +0200
--- trunk/gcc/gimple.c 2010-08-11 15:34:55.000000000 +0200
*************** get_base_address (tree t)
*** 3009,3014 ****
--- 3009,3017 ----
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
Index: trunk/gcc/tree-dfa.c
===================================================================
*** trunk.orig/gcc/tree-dfa.c 2010-08-11 15:27:08.000000000 +0200
--- trunk/gcc/tree-dfa.c 2010-08-11 15:56:15.000000000 +0200
*************** get_ref_base_and_extent (tree exp, HOST_
*** 878,883 ****
--- 878,914 ----
}
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;
}
*************** get_addr_base_and_unit_offset (tree exp,
*** 1010,1015 ****
--- 1041,1062 ----
}
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;
}
Index: trunk/gcc/tree-ssa-alias.c
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.c 2010-08-11 12:44:30.000000000 +0200
--- trunk/gcc/tree-ssa-alias.c 2010-08-11 15:55:28.000000000 +0200
*************** indirect_ref_may_alias_decl_p (tree ref1
*** 687,699 ****
alias_set_type ref2_alias_set,
alias_set_type base2_alias_set, bool tbaa_p)
{
! tree ptr1 = TREE_OPERAND (base1, 0);
tree ptrtype1;
HOST_WIDE_INT offset1p = offset1, offset2p = offset2;
/* 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)
{
double_int moff = mem_ref_offset (base1);
moff = double_int_lshift (moff,
--- 687,710 ----
alias_set_type ref2_alias_set,
alias_set_type base2_alias_set, bool tbaa_p)
{
! 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
! || TREE_CODE (base1) == TARGET_MEM_REF)
{
double_int moff = mem_ref_offset (base1);
moff = double_int_lshift (moff,
*************** indirect_ref_may_alias_decl_p (tree ref1
*** 711,717 ****
(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))
return false;
if (!ptr_deref_may_alias_decl_p (ptr1, base2))
return false;
--- 722,729 ----
(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 ((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;
*************** indirect_ref_may_alias_decl_p (tree ref1
*** 722,727 ****
--- 734,741 ----
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);
*************** indirect_ref_may_alias_decl_p (tree ref1
*** 740,747 ****
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)
&& same_type_for_tbaa (TREE_TYPE (ptrtype1), TREE_TYPE (base2)) == 1)
return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
--- 754,762 ----
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) != 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);
*************** indirect_ref_may_alias_decl_p (tree ref1
*** 778,783 ****
--- 793,799 ----
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),
*************** indirect_refs_may_alias_p (tree ref1 ATT
*** 807,825 ****
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 ptrtype1, ptrtype2;
/* 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))
{
/* 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)
{
double_int moff = mem_ref_offset (base1);
moff = double_int_lshift (moff,
--- 823,873 ----
alias_set_type ref2_alias_set,
alias_set_type base2_alias_set, bool tbaa_p)
{
! 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)
! && (((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
! || TREE_CODE (base1) == TARGET_MEM_REF)
{
double_int moff = mem_ref_offset (base1);
moff = double_int_lshift (moff,
*************** indirect_refs_may_alias_p (tree ref1 ATT
*** 831,837 ****
else
offset1 += moff.low;
}
! if (TREE_CODE (base2) == MEM_REF)
{
double_int moff = mem_ref_offset (base2);
moff = double_int_lshift (moff,
--- 879,886 ----
else
offset1 += moff.low;
}
! if (TREE_CODE (base2) == MEM_REF
! || TREE_CODE (base2) == TARGET_MEM_REF)
{
double_int moff = mem_ref_offset (base2);
moff = double_int_lshift (moff,
*************** indirect_refs_may_alias_p (tree ref1 ATT
*** 854,863 ****
--- 903,916 ----
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);
*************** indirect_refs_may_alias_p (tree ref1 ATT
*** 874,881 ****
/* 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)
&& (TREE_CODE (base2) != MEM_REF
|| same_type_for_tbaa (TREE_TYPE (base2), TREE_TYPE (ptrtype2)) == 1)
&& same_type_for_tbaa (TREE_TYPE (ptrtype1),
--- 927,936 ----
/* 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) != 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),
*************** indirect_refs_may_alias_p (tree ref1 ATT
*** 891,896 ****
--- 946,953 ----
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
*************** refs_may_alias_p_1 (ao_ref *ref1, ao_ref
*** 968,975 ****
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);
/* Canonicalize the pointer-vs-decl case. */
if (ind1_p && var2_p)
--- 1025,1036 ----
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)
! || (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)
*************** refs_may_alias_p_1 (ao_ref *ref1, ao_ref
*** 994,1006 ****
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,
--- 1055,1060 ----