diff options
author | Richard Guenther <rguenther@suse.de> | 2010-04-19 13:36:54 +0000 |
---|---|---|
committer | Richard Guenther <rguenther@suse.de> | 2010-04-19 13:36:54 +0000 |
commit | 9abc35e291baa23b3f3a7c662e5ac1d794346fda (patch) | |
tree | abc95b452bb0ec3c0f5823a4ec430430ab30b999 /gcc/tree-ssa-pre.c | |
parent | e95e0eb694f5cb731202bf3c67f1575dcefa8dfa (diff) |
2010-04-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43783
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Drop
constant ARRAY_REF operands two and three if possible.
* gcc.c-torture/execute/pr43783.c: New testcase.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@158517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r-- | gcc/tree-ssa-pre.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index ae630df1b48..dd9fb96dd5c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2779,22 +2779,37 @@ create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, return NULL_TREE; if (genop2) { - op2expr = get_or_alloc_expr_for (genop2); - genop2 = find_or_generate_expression (block, op2expr, stmts, - domstmt); - if (!genop2) - return NULL_TREE; + /* Drop zero minimum index. */ + if (tree_int_cst_equal (genop2, integer_zero_node)) + genop2 = NULL_TREE; + else + { + op2expr = get_or_alloc_expr_for (genop2); + genop2 = find_or_generate_expression (block, op2expr, stmts, + domstmt); + if (!genop2) + return NULL_TREE; + } } if (genop3) { tree elmt_type = TREE_TYPE (TREE_TYPE (genop0)); - genop3 = size_binop (EXACT_DIV_EXPR, genop3, - size_int (TYPE_ALIGN_UNIT (elmt_type))); - op3expr = get_or_alloc_expr_for (genop3); - genop3 = find_or_generate_expression (block, op3expr, stmts, - domstmt); - if (!genop3) - return NULL_TREE; + /* We can't always put a size in units of the element alignment + here as the element alignment may be not visible. See + PR43783. Simply drop the element size for constant + sizes. */ + if (tree_int_cst_equal (genop3, TYPE_SIZE_UNIT (elmt_type))) + genop3 = NULL_TREE; + else + { + genop3 = size_binop (EXACT_DIV_EXPR, genop3, + size_int (TYPE_ALIGN_UNIT (elmt_type))); + op3expr = get_or_alloc_expr_for (genop3); + genop3 = find_or_generate_expression (block, op3expr, stmts, + domstmt); + if (!genop3) + return NULL_TREE; + } } return build4 (currop->opcode, currop->type, genop0, genop1, genop2, genop3); |