This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][mem-ref2] Fixup selfassing plugin
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Jun 2010 13:19:35 +0200 (CEST)
- Subject: [PATCH][mem-ref2] Fixup selfassing plugin
... a piece of bad engineering.
Committed.
Richard.
2010-06-10 Richard Guenther <rguenther@suse.de>
* gcc.dg/plugin/selfassign.c: Fixup for MEM_REF.
* g++.dg/plugin/selfassign.c: Likewise.
Index: gcc/testsuite/g++.dg/plugin/selfassign.c
===================================================================
*** gcc/testsuite/g++.dg/plugin/selfassign.c (revision 160434)
--- gcc/testsuite/g++.dg/plugin/selfassign.c (working copy)
*************** get_real_ref_rhs (tree expr)
*** 52,60 ****
/* We are only interested in an assignment with a single
rhs operand because if it is not, the original assignment
will not possibly be a self-assignment. */
! if (is_gimple_assign (def_stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt))
! == GIMPLE_SINGLE_RHS))
return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt));
else
return NULL_TREE;
--- 52,58 ----
/* We are only interested in an assignment with a single
rhs operand because if it is not, the original assignment
will not possibly be a self-assignment. */
! if (gimple_assign_single_p (def_stmt))
return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt));
else
return NULL_TREE;
*************** get_real_ref_rhs (tree expr)
*** 66,72 ****
case PARM_DECL:
case FIELD_DECL:
case COMPONENT_REF:
! case INDIRECT_REF:
case ARRAY_REF:
return expr;
default:
--- 64,70 ----
case PARM_DECL:
case FIELD_DECL:
case COMPONENT_REF:
! case MEM_REF:
case ARRAY_REF:
return expr;
default:
*************** get_non_ssa_expr (tree expr)
*** 116,132 ****
else
return expr;
}
! case INDIRECT_REF:
{
tree orig_base = TREE_OPERAND (expr, 0);
! tree base = get_non_ssa_expr (orig_base);
! if (!base)
! return NULL_TREE;
! /* If BASE is converted, build a new indirect reference tree. */
! if (base != orig_base)
! return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (base)), base);
! else
! return expr;
}
case ARRAY_REF:
{
--- 114,131 ----
else
return expr;
}
! case MEM_REF:
{
tree orig_base = TREE_OPERAND (expr, 0);
! if (TREE_CODE (orig_base) == SSA_NAME)
! {
! tree base = get_non_ssa_expr (orig_base);
! if (!base)
! return NULL_TREE;
! return fold_build2 (MEM_REF, TREE_TYPE (expr),
! base, TREE_OPERAND (expr, 1));
! }
! return expr;
}
case ARRAY_REF:
{
*************** get_non_ssa_expr (tree expr)
*** 153,161 ****
&& !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
{
gimple def_stmt = SSA_NAME_DEF_STMT (expr);
! if (is_gimple_assign (def_stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt))
! == GIMPLE_SINGLE_RHS))
vdecl = gimple_assign_rhs1 (def_stmt);
}
return get_non_ssa_expr (vdecl);
--- 152,158 ----
&& !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
{
gimple def_stmt = SSA_NAME_DEF_STMT (expr);
! if (gimple_assign_single_p (def_stmt))
vdecl = gimple_assign_rhs1 (def_stmt);
}
return get_non_ssa_expr (vdecl);
*************** warn_self_assign (gimple stmt)
*** 201,209 ****
tree rhs, lhs;
/* Check assigment statement. */
! if (is_gimple_assign (stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (stmt))
! == GIMPLE_SINGLE_RHS))
{
rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt));
if (!rhs)
--- 198,204 ----
tree rhs, lhs;
/* Check assigment statement. */
! if (gimple_assign_single_p (stmt))
{
rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt));
if (!rhs)
Index: gcc/testsuite/gcc.dg/plugin/selfassign.c
===================================================================
*** gcc/testsuite/gcc.dg/plugin/selfassign.c (revision 160434)
--- gcc/testsuite/gcc.dg/plugin/selfassign.c (working copy)
*************** get_real_ref_rhs (tree expr)
*** 52,60 ****
/* We are only interested in an assignment with a single
rhs operand because if it is not, the original assignment
will not possibly be a self-assignment. */
! if (is_gimple_assign (def_stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt))
! == GIMPLE_SINGLE_RHS))
return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt));
else
return NULL_TREE;
--- 52,58 ----
/* We are only interested in an assignment with a single
rhs operand because if it is not, the original assignment
will not possibly be a self-assignment. */
! if (gimple_assign_single_p (def_stmt))
return get_real_ref_rhs (gimple_assign_rhs1 (def_stmt));
else
return NULL_TREE;
*************** get_real_ref_rhs (tree expr)
*** 66,72 ****
case PARM_DECL:
case FIELD_DECL:
case COMPONENT_REF:
! case INDIRECT_REF:
case ARRAY_REF:
return expr;
default:
--- 64,70 ----
case PARM_DECL:
case FIELD_DECL:
case COMPONENT_REF:
! case MEM_REF:
case ARRAY_REF:
return expr;
default:
*************** get_non_ssa_expr (tree expr)
*** 116,132 ****
else
return expr;
}
! case INDIRECT_REF:
{
tree orig_base = TREE_OPERAND (expr, 0);
! tree base = get_non_ssa_expr (orig_base);
! if (!base)
! return NULL_TREE;
! /* If BASE is converted, build a new indirect reference tree. */
! if (base != orig_base)
! return build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (base)), base);
! else
! return expr;
}
case ARRAY_REF:
{
--- 114,131 ----
else
return expr;
}
! case MEM_REF:
{
tree orig_base = TREE_OPERAND (expr, 0);
! if (TREE_CODE (orig_base) == SSA_NAME)
! {
! tree base = get_non_ssa_expr (orig_base);
! if (!base)
! return NULL_TREE;
! return fold_build2 (MEM_REF, TREE_TYPE (expr),
! base, TREE_OPERAND (expr, 1));
! }
! return expr;
}
case ARRAY_REF:
{
*************** get_non_ssa_expr (tree expr)
*** 153,161 ****
&& !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
{
gimple def_stmt = SSA_NAME_DEF_STMT (expr);
! if (is_gimple_assign (def_stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (def_stmt))
! == GIMPLE_SINGLE_RHS))
vdecl = gimple_assign_rhs1 (def_stmt);
}
return get_non_ssa_expr (vdecl);
--- 152,158 ----
&& !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
{
gimple def_stmt = SSA_NAME_DEF_STMT (expr);
! if (gimple_assign_single_p (def_stmt))
vdecl = gimple_assign_rhs1 (def_stmt);
}
return get_non_ssa_expr (vdecl);
*************** warn_self_assign (gimple stmt)
*** 201,209 ****
tree rhs, lhs;
/* Check assigment statement. */
! if (is_gimple_assign (stmt)
! && (get_gimple_rhs_class (gimple_assign_rhs_code (stmt))
! == GIMPLE_SINGLE_RHS))
{
rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt));
if (!rhs)
--- 198,204 ----
tree rhs, lhs;
/* Check assigment statement. */
! if (gimple_assign_single_p (stmt))
{
rhs = get_real_ref_rhs (gimple_assign_rhs1 (stmt));
if (!rhs)