From patchwork Wed Jul 14 12:17:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix PR44824 Date: Wed, 14 Jul 2010 02:17:06 -0000 From: Richard Guenther X-Patchwork-Id: 58883 Message-Id: To: gcc-patches@gcc.gnu.org Appearantly somebody decided that some VAR_DECLs do not have function invariant addresses. This makes them unsuitable for the first operand of MEM_REFs and thus we shouldn't create these invalid MEM_REFs from forwprop. Even though I question that predicates result the following fixes forwprop to deal with this. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2010-07-14 Richard Guenther PR tree-optimization/44824 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Use is_gimple_mem_ref_addr. (tree_ssa_forward_propagate_single_use_vars): Do not propagate non-decl_address_invariant_p addresses. Index: gcc/tree-ssa-forwprop.c =================================================================== --- gcc/tree-ssa-forwprop.c (revision 162140) +++ gcc/tree-ssa-forwprop.c (working copy) @@ -804,9 +804,7 @@ forward_propagate_addr_expr_1 (tree name fold_convert (ptr_type_node, gimple_assign_rhs2 (use_stmt))); if (TREE_CODE (new_def_rhs) == MEM_REF - && TREE_CODE (TREE_OPERAND (new_def_rhs, 0)) == ADDR_EXPR - && !DECL_P (TREE_OPERAND (TREE_OPERAND (new_def_rhs, 0), 0)) - && !CONSTANT_CLASS_P (TREE_OPERAND (TREE_OPERAND (new_def_rhs, 0), 0))) + && !is_gimple_mem_ref_addr (TREE_OPERAND (new_def_rhs, 0))) return false; new_def_rhs = build_fold_addr_expr_with_type (new_def_rhs, TREE_TYPE (rhs)); @@ -1398,8 +1396,11 @@ tree_ssa_forward_propagate_single_use_va && TREE_CODE (rhs) == ADDR_EXPR && POINTER_TYPE_P (TREE_TYPE (lhs)))) { - STRIP_NOPS (rhs); - if (!stmt_references_abnormal_ssa_name (stmt) + tree base = get_base_address (TREE_OPERAND (rhs, 0)); + if ((!base + || !DECL_P (base) + || decl_address_invariant_p (base)) + && !stmt_references_abnormal_ssa_name (stmt) && forward_propagate_addr_expr (lhs, rhs)) { release_defs (stmt);