From: Eric Botcazou Date: Thu, 14 Feb 2008 19:07:38 +0000 (+0000) Subject: re PR middle-end/35136 (ICE caused by address calculation with loop variable when... X-Git-Tag: releases/gcc-4.3.0~160 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=928bc34f5f3653e17357351b394894827aeef424;p=thirdparty%2Fgcc.git re PR middle-end/35136 (ICE caused by address calculation with loop variable when optimization is on) 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. From-SVN: r132320 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 936ae64ffbf8..d3dfe7ad70f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-02-14 Eric Botcazou + + 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. + 2008-02-14 Michael Matz PR target/34930 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index bc576a0ca002..04ed39c533a5 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6629,14 +6629,6 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var) pop_gimplify_context (NULL); - if (*stmts && gimple_in_ssa_p (cfun)) - { - tree_stmt_iterator tsi; - - for (tsi = tsi_start (*stmts); !tsi_end_p (tsi); tsi_next (&tsi)) - mark_symbols_for_renaming (tsi_stmt (tsi)); - } - return expr; } @@ -6656,6 +6648,14 @@ force_gimple_operand_bsi (block_stmt_iterator *bsi, tree expr, expr = force_gimple_operand (expr, &stmts, simple_p, var); if (stmts) { + if (gimple_in_ssa_p (cfun)) + { + tree_stmt_iterator tsi; + + for (tsi = tsi_start (stmts); !tsi_end_p (tsi); tsi_next (&tsi)) + mark_symbols_for_renaming (tsi_stmt (tsi)); + } + if (before) bsi_insert_before (bsi, stmts, m); else diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index ef7d64a268d2..6ff690dfaa9b 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