This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Some infrastructure for const propagation into PHIs
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 28 Jul 2003 11:12:58 -0600
- Subject: [tree-ssa] Some infrastructure for const propagation into PHIs
- Reply-to: law at redhat dot com
This patch includes a number of fixes required to allow us to propagate
constants into PHI nodes. We still have some problems handling this in
the out-of-ssa pass, and thus the propagation into PHI nodes isn't
enabled yet. But this kills the various places where we assumed that
PHI arguments are always SSA_NAMEs.
* tree-dfa.c (compute_immediate_uses_for): Do not assume that
PHI arguments are SSA_NAMEs.
* tree-ssa-dce.c (process_worklist): Likewise.
* tree-ssa-copyprop.c (copyprop_phi): Likewise. Use may_propagate_copy.
* tree-ssa-ccp.c (visit_phi_node): Do not assume that PHI arguments
are SSA_NAMEs. Create a suitable value if a PHI argument is a
constant.
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.135
diff -c -3 -p -r1.1.4.135 tree-dfa.c
*** tree-dfa.c 25 Jul 2003 03:13:07 -0000 1.1.4.135
--- tree-dfa.c 28 Jul 2003 17:06:00 -0000
*************** compute_immediate_uses_for (tree stmt, i
*** 1048,1056 ****
for (i = 0; i < PHI_NUM_ARGS (stmt); i++)
{
! tree imm_rdef_stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF (stmt, i));
! if (!IS_EMPTY_STMT (imm_rdef_stmt))
! add_immediate_use (imm_rdef_stmt, stmt);
}
return;
}
--- 1048,1061 ----
for (i = 0; i < PHI_NUM_ARGS (stmt); i++)
{
! tree arg = PHI_ARG_DEF (stmt, i);
!
! if (TREE_CODE (arg) == SSA_NAME)
! {
! tree imm_rdef_stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF (stmt, i));
! if (!IS_EMPTY_STMT (imm_rdef_stmt))
! add_immediate_use (imm_rdef_stmt, stmt);
! }
}
return;
}
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.79
diff -c -3 -p -r1.1.2.79 tree-ssa-ccp.c
*** tree-ssa-ccp.c 22 Jul 2003 18:36:38 -0000 1.1.2.79
--- tree-ssa-ccp.c 28 Jul 2003 17:06:01 -0000
*************** visit_phi_node (tree phi)
*** 398,404 ****
if (e->flags & EDGE_EXECUTABLE)
{
tree rdef = PHI_ARG_DEF (phi, i);
! value *rdef_val = get_value (rdef);
phi_val = cp_lattice_meet (phi_val, *rdef_val);
if (dump_file && (dump_flags & TDF_DETAILS))
--- 398,416 ----
if (e->flags & EDGE_EXECUTABLE)
{
tree rdef = PHI_ARG_DEF (phi, i);
! value *rdef_val;
!
! if (TREE_CONSTANT (rdef))
! {
! value val;
!
! val.lattice_val = CONSTANT;
! val.const_val = rdef;
! rdef_val = &val;
! }
! else
! rdef_val = get_value (rdef);
!
phi_val = cp_lattice_meet (phi_val, *rdef_val);
if (dump_file && (dump_flags & TDF_DETAILS))
Index: tree-ssa-copyprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-copyprop.c,v
retrieving revision 1.1.2.10
diff -c -3 -p -r1.1.2.10 tree-ssa-copyprop.c
*** tree-ssa-copyprop.c 23 Jul 2003 23:48:16 -0000 1.1.2.10
--- tree-ssa-copyprop.c 28 Jul 2003 17:06:03 -0000
*************** copyprop_phi (tree phi)
*** 150,160 ****
for (i = 0; i < PHI_NUM_ARGS (phi); i++)
{
tree arg = PHI_ARG_DEF (phi, i);
! tree orig = get_original (arg);
! if (orig
! && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (arg)
! && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig))
{
if (dump_file && dump_flags & TDF_DETAILS)
{
--- 150,162 ----
for (i = 0; i < PHI_NUM_ARGS (phi); i++)
{
tree arg = PHI_ARG_DEF (phi, i);
! tree orig;
! if (TREE_CODE (arg) != SSA_NAME)
! continue;
!
! orig = get_original (arg);
! if (orig && may_propagate_copy (arg, orig))
{
if (dump_file && dump_flags & TDF_DETAILS)
{
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.47
diff -c -3 -p -r1.1.2.47 tree-ssa-dce.c
*** tree-ssa-dce.c 22 Jul 2003 02:50:15 -0000 1.1.2.47
--- tree-ssa-dce.c 28 Jul 2003 17:06:03 -0000
*************** process_worklist (void)
*** 357,363 ****
/* All the statements feeding this PHI node's arguments are
necessary. */
for (k = 0; k < PHI_NUM_ARGS (i); k++)
! mark_necessary (SSA_NAME_DEF_STMT (PHI_ARG_DEF (i, k)));
/* Look at all the predecessors, and if this PHI is being fed
from a conditional expression, mark that conditional
--- 357,367 ----
/* All the statements feeding this PHI node's arguments are
necessary. */
for (k = 0; k < PHI_NUM_ARGS (i); k++)
! {
! tree arg = PHI_ARG_DEF (i, k);
! if (TREE_CODE (arg) == SSA_NAME)
! mark_necessary (SSA_NAME_DEF_STMT (PHI_ARG_DEF (i, k)));
! }
/* Look at all the predecessors, and if this PHI is being fed
from a conditional expression, mark that conditional