mirror of git://gcc.gnu.org/git/gcc.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
This commit is contained in:
parent
4bcf935d11
commit
928bc34f5f
|
|
@ -1,3 +1,14 @@
|
||||||
|
2008-02-14 Eric Botcazou <ebotcazou@adacore.com>
|
||||||
|
|
||||||
|
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 <matz@suse.de>
|
2008-02-14 Michael Matz <matz@suse.de>
|
||||||
|
|
||||||
PR target/34930
|
PR target/34930
|
||||||
|
|
|
||||||
|
|
@ -6629,14 +6629,6 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
|
||||||
|
|
||||||
pop_gimplify_context (NULL);
|
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;
|
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);
|
expr = force_gimple_operand (expr, &stmts, simple_p, var);
|
||||||
if (stmts)
|
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)
|
if (before)
|
||||||
bsi_insert_before (bsi, stmts, m);
|
bsi_insert_before (bsi, stmts, m);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1434,21 +1434,34 @@ may_be_nonaddressable_p (tree expr)
|
||||||
{
|
{
|
||||||
switch (TREE_CODE (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:
|
case COMPONENT_REF:
|
||||||
return DECL_NONADDRESSABLE_P (TREE_OPERAND (expr, 1))
|
return DECL_NONADDRESSABLE_P (TREE_OPERAND (expr, 1))
|
||||||
|| may_be_nonaddressable_p (TREE_OPERAND (expr, 0));
|
|| 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:
|
case VIEW_CONVERT_EXPR:
|
||||||
/* This kind of view-conversions may wrap non-addressable objects
|
/* This kind of view-conversions may wrap non-addressable objects
|
||||||
and make them look addressable. After some processing the
|
and make them look addressable. After some processing the
|
||||||
non-addressability may be uncovered again, causing ADDR_EXPRs
|
non-addressability may be uncovered again, causing ADDR_EXPRs
|
||||||
of inappropriate objects to be built. */
|
of inappropriate objects to be built. */
|
||||||
return AGGREGATE_TYPE_P (TREE_TYPE (expr))
|
if (AGGREGATE_TYPE_P (TREE_TYPE (expr))
|
||||||
&& !AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0)));
|
&& !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:
|
default:
|
||||||
break;
|
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)
|
if (TREE_CODE (base) == BIT_FIELD_REF)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (may_be_nonaddressable_p (base))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (STRICT_ALIGNMENT
|
|
||||||
&& may_be_unaligned_p (base))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
base = unshare_expr (base);
|
base = unshare_expr (base);
|
||||||
|
|
||||||
if (TREE_CODE (base) == TARGET_MEM_REF)
|
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) != ALIGN_INDIRECT_REF);
|
||||||
gcc_assert (TREE_CODE (base) != MISALIGNED_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);
|
base = build_fold_addr_expr (base);
|
||||||
|
|
||||||
/* Substituting bases of IVs into the base expression might
|
/* Substituting bases of IVs into the base expression might
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue