diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2008-02-14 19:07:38 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2008-02-14 19:07:38 +0000 |
commit | 8e60ee88360b2bea4337e6dc58e61331f6939401 (patch) | |
tree | 179f616f6f526bdb6070315bbfbf22e717f577d5 /gcc/tree-ssa-loop-ivopts.c | |
parent | b2ef2b58e30524a42bdc5b459d57c91e5d08ed95 (diff) |
PR middle-end/35136
* gimplify.c (force_gimple_operand_bsi): Revert 2008-02-12 change.
(force_gimple_operand): Likewise.
* tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Add new cases
for TARGET_MEM_REF and CONVERT_EXPR/NON_LVALUE_EXPR/NOP_EXPR.
Also recurse on the operand for regular VIEW_CONVERT_EXPRs.
(find_interesting_uses_address): Check addressability and alignment
of the base expression only after substituting bases of IVs into it.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@132320 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index ef7d64a268d..6ff690dfaa9 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1434,21 +1434,34 @@ may_be_nonaddressable_p (tree expr) { switch (TREE_CODE (expr)) { + case TARGET_MEM_REF: + /* TARGET_MEM_REFs are translated directly to valid MEMs on the + target, thus they are always addressable. */ + return false; + case COMPONENT_REF: return DECL_NONADDRESSABLE_P (TREE_OPERAND (expr, 1)) || may_be_nonaddressable_p (TREE_OPERAND (expr, 0)); - case ARRAY_REF: - case ARRAY_RANGE_REF: - return may_be_nonaddressable_p (TREE_OPERAND (expr, 0)); - case VIEW_CONVERT_EXPR: /* This kind of view-conversions may wrap non-addressable objects and make them look addressable. After some processing the non-addressability may be uncovered again, causing ADDR_EXPRs of inappropriate objects to be built. */ - return AGGREGATE_TYPE_P (TREE_TYPE (expr)) - && !AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0))); + if (AGGREGATE_TYPE_P (TREE_TYPE (expr)) + && !AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0)))) + return true; + + /* ... fall through ... */ + + case ARRAY_REF: + case ARRAY_RANGE_REF: + return may_be_nonaddressable_p (TREE_OPERAND (expr, 0)); + + case CONVERT_EXPR: + case NON_LVALUE_EXPR: + case NOP_EXPR: + return true; default: break; @@ -1476,13 +1489,6 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p) if (TREE_CODE (base) == BIT_FIELD_REF) goto fail; - if (may_be_nonaddressable_p (base)) - goto fail; - - if (STRICT_ALIGNMENT - && may_be_unaligned_p (base)) - goto fail; - base = unshare_expr (base); if (TREE_CODE (base) == TARGET_MEM_REF) @@ -1536,6 +1542,16 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p) gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF); gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF); + /* Check that the base expression is addressable. This needs + to be done after substituting bases of IVs into it. */ + if (may_be_nonaddressable_p (base)) + goto fail; + + /* Moreover, on strict alignment platforms, check that it is + sufficiently aligned. */ + if (STRICT_ALIGNMENT && may_be_unaligned_p (base)) + goto fail; + base = build_fold_addr_expr (base); /* Substituting bases of IVs into the base expression might |