From 150594ba69066ade4b78e51d0a20ef9a16029bc2 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Sat, 26 May 2007 03:29:58 +0000 Subject: [PATCH] re PR tree-optimization/32090 (ICE in forwprop with zero sized array) 2007-05-25 Andrew Pinski PR tree-opt/32090 * tree-ssa-forwprop.c (forward_propagate_addr_into_variable_array_index): Remove the lhs argument. Use the type of def_rhs instead of lhs. (forward_propagate_addr_expr_1): Update use of forward_propagate_addr_into_variable_array_index. 2007-05-25 Andrew Pinski PR tree-opt/32090 * g++.dg/opt/array2.C: New testcase. From-SVN: r125087 --- gcc/ChangeLog | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/array2.C | 11 +++++++++++ gcc/tree-ssa-forwprop.c | 14 +++++++------- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/array2.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79bb878..c85ce33 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2007-05-25 Andrew Pinski + + PR tree-opt/32090 + * tree-ssa-forwprop.c + (forward_propagate_addr_into_variable_array_index): Remove + the lhs argument. Use the type of def_rhs instead of lhs. + (forward_propagate_addr_expr_1): Update use of + forward_propagate_addr_into_variable_array_index. + 2007-05-25 Sandra Loosemore Nigel Stephens diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59b1939..66ba361 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-05-25 Andrew Pinski + + PR tree-opt/32090 + * g++.dg/opt/array2.C: New testcase. + 007-05-26 Uros Bizjak PR target/32065 diff --git a/gcc/testsuite/g++.dg/opt/array2.C b/gcc/testsuite/g++.dg/opt/array2.C new file mode 100644 index 0000000..b40b052 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/array2.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +struct JArray +{ + int data[1]; +}; +void *copyIntoByteArray (struct JArray *dest, __SIZE_TYPE__ offset) +{ + void *pdest = dest->data + offset; + return pdest; +} diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 143268e3..e42406c 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -478,8 +478,8 @@ tidy_after_forward_propagate_addr (tree stmt) mark_symbols_for_renaming (stmt); } -/* DEF_RHS defines LHS which is contains the address of the 0th element - in an array. USE_STMT uses LHS to compute the address of an +/* DEF_RHS contains the address of the 0th element in an array. + USE_STMT uses type of DEF_RHS to compute the address of an arbitrary element within the array. The (variable) byte offset of the element is contained in OFFSET. @@ -494,7 +494,7 @@ tidy_after_forward_propagate_addr (tree stmt) with the new address computation. */ static bool -forward_propagate_addr_into_variable_array_index (tree offset, tree lhs, +forward_propagate_addr_into_variable_array_index (tree offset, tree def_rhs, tree use_stmt) { tree index; @@ -516,7 +516,7 @@ forward_propagate_addr_into_variable_array_index (tree offset, tree lhs, /* 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. */ - if (integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (lhs))))) + if (integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (def_rhs))))) index = offset; else { @@ -531,7 +531,7 @@ forward_propagate_addr_into_variable_array_index (tree offset, tree lhs, if (TREE_CODE (offset) != MULT_EXPR || TREE_CODE (TREE_OPERAND (offset, 1)) != INTEGER_CST || !simple_cst_equal (TREE_OPERAND (offset, 1), - TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (lhs))))) + TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (def_rhs))))) return false; /* The first operand to the MULT_EXPR is the desired index. */ @@ -679,7 +679,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, tree use_stmt, bool res; tree offset_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 1)); - res = forward_propagate_addr_into_variable_array_index (offset_stmt, lhs, + res = forward_propagate_addr_into_variable_array_index (offset_stmt, def_rhs, use_stmt); return res; } @@ -694,7 +694,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, tree use_stmt, { bool res; tree offset_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0)); - res = forward_propagate_addr_into_variable_array_index (offset_stmt, lhs, + res = forward_propagate_addr_into_variable_array_index (offset_stmt, def_rhs, use_stmt); return res; } -- 2.7.4