[ tree-ssa] PRE problem
law@redhat.com
law@redhat.com
Fri Feb 20 19:56:00 GMT 2004
In message <1077304036.3169.162.camel@localhost.localdomain>, Diego Novillo wri
tes:
>
>See if this (untested) patch fixes your problem. We were not calling
>propagate_value in generate_expr_as_of_bb. This fixes PR14153, but I
>haven't checked other places in PRE where we may be doing the same.
I think something like this is what we need:
I'm primarily concerned about having EREF_STMT pointing to NULL in the
case where we could not generate the expression. I just don't know the
code well enough to know if that might trigger undesirable effects.
I believe we also want to make propagate_copy static and only export the more
generic propagate_value.
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.129
diff -c -p -r1.1.4.129 tree-ssa-pre.c
*** tree-ssa-pre.c 30 Jan 2004 13:14:18 -0000 1.1.4.129
--- tree-ssa-pre.c 20 Feb 2004 19:45:00 -0000
*************** static tree create_ephi_node (basic_bloc
*** 142,148 ****
static inline int opnum_of_phi (tree, int);
static inline int opnum_of_ephi (const tree, const edge);
static tree subst_phis (struct expr_info *, tree, basic_block, basic_block);
! static void generate_expr_as_of_bb (tree, basic_block, basic_block);
static void generate_vops_as_of_bb (tree, basic_block, basic_block);
static void rename_1 (struct expr_info *);
static void process_delayed_rename (struct expr_info *, tree, tree);
--- 142,148 ----
static inline int opnum_of_phi (tree, int);
static inline int opnum_of_ephi (const tree, const edge);
static tree subst_phis (struct expr_info *, tree, basic_block, basic_block);
! static bool generate_expr_as_of_bb (tree, basic_block, basic_block);
static void generate_vops_as_of_bb (tree, basic_block, basic_block);
static void rename_1 (struct expr_info *);
static void process_delayed_rename (struct expr_info *, tree, tree);
*************** opnum_of_phi (tree phi, int j)
*** 1202,1210 ****
/* Generate EXPR as it would look in basic block PRED (using the phi in
block BB). We do this by replacing the variables with the phi
argument definitions for block J if they are defined by a phi in
! block BB. */
! static void
generate_expr_as_of_bb (tree expr, basic_block pred, basic_block bb)
{
use_optype uses = STMT_USE_OPS (expr);
--- 1202,1213 ----
/* Generate EXPR as it would look in basic block PRED (using the phi in
block BB). We do this by replacing the variables with the phi
argument definitions for block J if they are defined by a phi in
! block BB.
! Return TRUE if we were able to generate the expression, otherwise
! return otherwise. */
!
! static bool
generate_expr_as_of_bb (tree expr, basic_block pred, basic_block bb)
{
use_optype uses = STMT_USE_OPS (expr);
*************** generate_expr_as_of_bb (tree expr, basic
*** 1223,1229 ****
{
int opnum = opnum_of_phi (phi, pred->index);
tree p = PHI_ARG_DEF (phi, opnum);
! *vp = p;
if (!phi_ssa_name_p (p))
replaced_constants = true;
break;
--- 1226,1234 ----
{
int opnum = opnum_of_phi (phi, pred->index);
tree p = PHI_ARG_DEF (phi, opnum);
! if (! may_propagate_copy (*vp, p))
! return false;
! propagate_value (vp, p);
if (!phi_ssa_name_p (p))
replaced_constants = true;
break;
*************** subst_phis (struct expr_info *ei, tree Z
*** 1285,1291 ****
create_stmt_ann (stmt_copy);
modify_stmt (stmt_copy);
get_stmt_operands (stmt_copy);
! generate_expr_as_of_bb (stmt_copy, pred, bb);
set_bb_for_stmt (stmt_copy, bb);
modify_stmt (stmt_copy);
get_stmt_operands (stmt_copy);
--- 1290,1297 ----
create_stmt_ann (stmt_copy);
modify_stmt (stmt_copy);
get_stmt_operands (stmt_copy);
! if (! generate_expr_as_of_bb (stmt_copy, pred, bb))
! return NULL;
set_bb_for_stmt (stmt_copy, bb);
modify_stmt (stmt_copy);
get_stmt_operands (stmt_copy);
*************** process_delayed_rename (struct expr_info
*** 1528,1535 ****
{
tree tmp_use = EPHI_ARG_PRED (exp_phi, opnd_num);
EREF_STMT (tmp_use) = newexp;
! if (same_e_version_phi_result (ei, def, newexp,
! tmp_use))
{
if (EREF_INJURED (tmp_use))
--- 1534,1541 ----
{
tree tmp_use = EPHI_ARG_PRED (exp_phi, opnd_num);
EREF_STMT (tmp_use) = newexp;
! if (newexp
! && same_e_version_phi_result (ei, def, newexp, tmp_use))
{
if (EREF_INJURED (tmp_use))
*************** process_delayed_rename (struct expr_info
*** 1563,1571 ****
else if (TREE_CODE (def) == EUSE_NODE && !EUSE_PHIOP (def))
{
bool injured = false;
! if (same_e_version_real_occ_phi_opnd (ei, def,
! bb_for_stmt (use),
! opnd_num, newexp, &injured))
{
tree tmp_use = EPHI_ARG_PRED (exp_phi, opnd_num);
EPHI_ARG_HAS_REAL_USE (exp_phi, opnd_num) = true;
--- 1569,1580 ----
else if (TREE_CODE (def) == EUSE_NODE && !EUSE_PHIOP (def))
{
bool injured = false;
! if (newexp
! && same_e_version_real_occ_phi_opnd (ei, def,
! bb_for_stmt (use),
! opnd_num,
! newexp,
! &injured))
{
tree tmp_use = EPHI_ARG_PRED (exp_phi, opnd_num);
EPHI_ARG_HAS_REAL_USE (exp_phi, opnd_num) = true;
More information about the Gcc
mailing list