aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-data-ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-data-ref.c')
-rw-r--r--gcc/tree-data-ref.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index c41cf51f775..e7aa277a69f 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -746,7 +746,22 @@ dr_analyze_innermost (struct data_reference *dr)
return false;
}
- base = build_fold_addr_expr (base);
+ if (TREE_CODE (base) == MEM_REF)
+ {
+ if (!integer_zerop (TREE_OPERAND (base, 1)))
+ {
+ if (!poffset)
+ {
+ double_int moff = mem_ref_offset (base);
+ poffset = double_int_to_tree (sizetype, moff);
+ }
+ else
+ poffset = size_binop (PLUS_EXPR, poffset, TREE_OPERAND (base, 1));
+ }
+ base = TREE_OPERAND (base, 0);
+ }
+ else
+ base = build_fold_addr_expr (base);
if (in_loop)
{
if (!simple_iv (loop, loop_containing_stmt (stmt), base, &base_iv,
@@ -844,13 +859,18 @@ dr_analyze_indices (struct data_reference *dr, struct loop *nest)
aref = TREE_OPERAND (aref, 0);
}
- if (nest && INDIRECT_REF_P (aref))
+ if (nest
+ && (INDIRECT_REF_P (aref)
+ || TREE_CODE (aref) == MEM_REF))
{
op = TREE_OPERAND (aref, 0);
access_fn = analyze_scalar_evolution (loop, op);
access_fn = instantiate_scev (before_loop, loop, access_fn);
base = initial_condition (access_fn);
split_constant_offset (base, &base, &off);
+ if (TREE_CODE (aref) == MEM_REF)
+ off = size_binop (PLUS_EXPR, off,
+ fold_convert (ssizetype, TREE_OPERAND (aref, 1)));
access_fn = chrec_replace_initial_condition (access_fn,
fold_convert (TREE_TYPE (base), off));
@@ -858,6 +878,22 @@ dr_analyze_indices (struct data_reference *dr, struct loop *nest)
VEC_safe_push (tree, heap, access_fns, access_fn);
}
+ if (TREE_CODE (aref) == MEM_REF)
+ TREE_OPERAND (aref, 1)
+ = build_int_cst (TREE_TYPE (TREE_OPERAND (aref, 1)), 0);
+
+ if (TREE_CODE (ref) == MEM_REF
+ && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR
+ && integer_zerop (TREE_OPERAND (ref, 1)))
+ ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0);
+
+ /* For canonicalization purposes we'd like to strip all outermost
+ zero-offset component-refs.
+ ??? For now simply handle zero-index array-refs. */
+ while (TREE_CODE (ref) == ARRAY_REF
+ && integer_zerop (TREE_OPERAND (ref, 1)))
+ ref = TREE_OPERAND (ref, 0);
+
DR_BASE_OBJECT (dr) = ref;
DR_ACCESS_FNS (dr) = access_fns;
}
@@ -870,7 +906,8 @@ dr_analyze_alias (struct data_reference *dr)
tree ref = DR_REF (dr);
tree base = get_base_address (ref), addr;
- if (INDIRECT_REF_P (base))
+ if (INDIRECT_REF_P (base)
+ || TREE_CODE (base) == MEM_REF)
{
addr = TREE_OPERAND (base, 0);
if (TREE_CODE (addr) == SSA_NAME)
@@ -1188,7 +1225,8 @@ object_address_invariant_in_loop_p (const struct loop *loop, const_tree obj)
obj = TREE_OPERAND (obj, 0);
}
- if (!INDIRECT_REF_P (obj))
+ if (!INDIRECT_REF_P (obj)
+ && TREE_CODE (obj) != MEM_REF)
return true;
return !chrec_contains_symbols_defined_in_loop (TREE_OPERAND (obj, 0),
@@ -1414,7 +1452,14 @@ initialize_data_dependence_relation (struct data_reference *a,
return res;
}
- gcc_assert (DR_NUM_DIMENSIONS (a) == DR_NUM_DIMENSIONS (b));
+ /* If the number of dimensions of the access to not agree we can have
+ a pointer access to a component of the array element type and an
+ array access while the base-objects are still the same. Punt. */
+ if (DR_NUM_DIMENSIONS (a) != DR_NUM_DIMENSIONS (b))
+ {
+ DDR_ARE_DEPENDENT (res) = chrec_dont_know;
+ return res;
+ }
DDR_AFFINE_P (res) = true;
DDR_ARE_DEPENDENT (res) = NULL_TREE;