[PATCH][mem-ref2] More fixes
Richard Guenther
rguenther@suse.de
Fri Apr 9 08:56:00 GMT 2010
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-04-09 Richard Guenther <rguenther@suse.de>
* builtins.c (maybe_emit_free_warning): Handle MEM_REF.
* tree-ssa-phiopt.c (add_or_mark_expr): Likewise.
(cond_store_replacement): Likewise.
* tree-ssa-phiprop.c (phiprop_insert_phi): Likewise.
(propagate_with_phi): Likewise.
* tree-object-size.c (addr_object_size): Complete MEM_REF
handling, fix error in previous conversion.
Index: builtins.c
===================================================================
*** builtins.c (revision 158111)
--- builtins.c (working copy)
*************** maybe_emit_free_warning (tree exp)
*** 11887,11893 ****
return;
arg = get_base_address (TREE_OPERAND (arg, 0));
! if (arg == NULL || INDIRECT_REF_P (arg))
return;
if (SSA_VAR_P (arg))
--- 11887,11893 ----
return;
arg = get_base_address (TREE_OPERAND (arg, 0));
! if (arg == NULL || INDIRECT_REF_P (arg) || TREE_CODE (arg) == MEM_REF)
return;
if (SSA_VAR_P (arg))
Index: tree-ssa-phiopt.c
===================================================================
*** tree-ssa-phiopt.c (revision 158111)
--- tree-ssa-phiopt.c (working copy)
*************** static void
*** 1057,1063 ****
add_or_mark_expr (basic_block bb, tree exp,
struct pointer_set_t *nontrap, bool store)
{
! if (INDIRECT_REF_P (exp)
&& TREE_CODE (TREE_OPERAND (exp, 0)) == SSA_NAME)
{
tree name = TREE_OPERAND (exp, 0);
--- 1057,1063 ----
add_or_mark_expr (basic_block bb, tree exp,
struct pointer_set_t *nontrap, bool store)
{
! if (TREE_CODE (exp) == MEM_REF
&& TREE_CODE (TREE_OPERAND (exp, 0)) == SSA_NAME)
{
tree name = TREE_OPERAND (exp, 0);
*************** cond_store_replacement (basic_block midd
*** 1202,1208 ****
locus = gimple_location (assign);
lhs = gimple_assign_lhs (assign);
rhs = gimple_assign_rhs1 (assign);
! if (!INDIRECT_REF_P (lhs))
return false;
/* RHS is either a single SSA_NAME or a constant. */
--- 1202,1209 ----
locus = gimple_location (assign);
lhs = gimple_assign_lhs (assign);
rhs = gimple_assign_rhs1 (assign);
! if (TREE_CODE (lhs) != MEM_REF
! || TREE_CODE (TREE_OPERAND (lhs, 0)) != SSA_NAME)
return false;
/* RHS is either a single SSA_NAME or a constant. */
Index: tree-ssa-phiprop.c
===================================================================
*** tree-ssa-phiprop.c (revision 158111)
--- tree-ssa-phiprop.c (working copy)
*************** phiprop_insert_phi (basic_block bb, gimp
*** 140,146 ****
edge e;
gcc_assert (is_gimple_assign (use_stmt)
! && gimple_assign_rhs_code (use_stmt) == INDIRECT_REF);
/* Build a new PHI node to replace the definition of
the indirect reference lhs. */
--- 140,146 ----
edge e;
gcc_assert (is_gimple_assign (use_stmt)
! && gimple_assign_rhs_code (use_stmt) == MEM_REF);
/* Build a new PHI node to replace the definition of
the indirect reference lhs. */
*************** propagate_with_phi (basic_block bb, gimp
*** 299,306 ****
/* Check whether this is a load of *ptr. */
if (!(is_gimple_assign (use_stmt)
&& TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME
! && gimple_assign_rhs_code (use_stmt) == INDIRECT_REF
&& TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == ptr
/* We cannot replace a load that may throw or is volatile. */
&& !stmt_can_throw_internal (use_stmt)))
continue;
--- 299,309 ----
/* Check whether this is a load of *ptr. */
if (!(is_gimple_assign (use_stmt)
&& TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME
! && gimple_assign_rhs_code (use_stmt) == MEM_REF
&& TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == ptr
+ && integer_zerop (TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 1))
+ && types_compatible_p (TREE_TYPE (gimple_assign_rhs1 (use_stmt)),
+ TREE_TYPE (TREE_TYPE (ptr)))
/* We cannot replace a load that may throw or is volatile. */
&& !stmt_can_throw_internal (use_stmt)))
continue;
Index: tree-object-size.c
===================================================================
*** tree-object-size.c (revision 158111)
--- tree-object-size.c (working copy)
*************** addr_object_size (struct object_size_inf
*** 180,186 ****
sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
object_size_type & ~1);
if (host_integerp (TREE_OPERAND (pt_var, 1), 0))
! sz += TREE_INT_CST_LOW (TREE_OPERAND (pt_var, 1));
else
sz = offset_limit;
}
--- 180,186 ----
sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
object_size_type & ~1);
if (host_integerp (TREE_OPERAND (pt_var, 1), 0))
! sz -= TREE_INT_CST_LOW (TREE_OPERAND (pt_var, 1));
else
sz = offset_limit;
}
*************** addr_object_size (struct object_size_inf
*** 194,199 ****
--- 194,203 ----
sz = object_sizes[object_size_type][SSA_NAME_VERSION (var)];
else
sz = unknown[object_size_type];
+ if (host_integerp (TREE_OPERAND (pt_var, 1), 0))
+ sz -= TREE_INT_CST_LOW (TREE_OPERAND (pt_var, 1));
+ else
+ sz = offset_limit;
}
if (sz != unknown[object_size_type] && sz < offset_limit)
More information about the Gcc-patches
mailing list