summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2008-12-02 15:30:55 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2008-12-02 15:30:55 +0100
commitd47a01516c91f35d0f60d2e636d6e3724ee400b3 (patch)
tree773f6a892e8147c25699be344fdb943a6a5c0ae3 /gcc/tree-ssa-forwprop.c
parent96e4a79fbd9ee3c390c77bc2bff69a783ee13ff2 (diff)
downloadgcc-d47a01516c91f35d0f60d2e636d6e3724ee400b3.tar.gz
re PR middle-end/37861 (Bogus array bounds warning)
2008-12-02 Martin Jambor <mjambor@suse.cz> PR middle-end/37861 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Do not check for INDIRECT_REFs. (forward_propagate_addr_into_variable_array_index): Check that the offset is not computed from a MULT_EXPR, use is_gimple_assign rather than the gimple code directly. From-SVN: r142355
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index b19879f7909..bfd7146d490 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -613,19 +613,27 @@ forward_propagate_addr_into_variable_array_index (tree offset,
tree index;
gimple offset_def, use_stmt = gsi_stmt (*use_stmt_gsi);
- /* Try to find an expression for a proper index. This is either
- a multiplication expression by the element size or just the
- ssa name we came along in case the element size is one. */
+ /* Get the offset's defining statement. */
+ offset_def = SSA_NAME_DEF_STMT (offset);
+
+ /* Try to find an expression for a proper index. This is either a
+ multiplication expression by the element size or just the ssa name we came
+ along in case the element size is one. In that case, however, we do not
+ allow multiplications because they can be computing index to a higher
+ level dimension (PR 37861). */
if (integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (def_rhs)))))
- index = offset;
- else
{
- /* Get the offset's defining statement. */
- offset_def = SSA_NAME_DEF_STMT (offset);
+ if (is_gimple_assign (offset_def)
+ && gimple_assign_rhs_code (offset_def) == MULT_EXPR)
+ return false;
+ index = offset;
+ }
+ else
+ {
/* The statement which defines OFFSET before type conversion
must be a simple GIMPLE_ASSIGN. */
- if (gimple_code (offset_def) != GIMPLE_ASSIGN)
+ if (!is_gimple_assign (offset_def))
return false;
/* The RHS of the statement which defines OFFSET must be a
@@ -805,9 +813,6 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
array_ref = TREE_OPERAND (def_rhs, 0);
if (TREE_CODE (array_ref) != ARRAY_REF
|| TREE_CODE (TREE_TYPE (TREE_OPERAND (array_ref, 0))) != ARRAY_TYPE
- /* Avoid accessing hidden multidimensional arrays in this way or VRP
- might give out bogus warnings (see PR 37861) */
- || TREE_CODE (TREE_OPERAND (array_ref, 0)) == INDIRECT_REF
|| !integer_zerop (TREE_OPERAND (array_ref, 1)))
return false;