This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Out of SSA status and issues
- From: law at redhat dot com
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: Diego Novillo <dnovillo at redhat dot com>, gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Mon, 12 May 2003 11:25:16 -0600
- Subject: Re: [tree-ssa] Out of SSA status and issues
- Reply-to: law at redhat dot com
In message <1052759521.3373.0.camel@p4>, Andrew MacLeod writes:
>> FWIW, I dug up my changes to identify the problem variables (those
>> occurring in abnormal PHIs) and cobbled together the two lines of
>> code necessary to use that information to avoid copy propagating
>> those variables during SSA renaming.
>>
>> Interested in playing with it to see if it resolves your problems?
>>
>Absolutely :-)
Here you go. Feel free to check it in if it resolves the problems to
your satisfaction.
* tree-flow.h (struct var_ann_d): New field occurs_in_abnormal_phi.
* tree-ssa.c (MAY_COPYPROP_P): Do not allow copy propagations
if either argument occurs in an abnormal phi.
* tree-dfa.c (add_phi_arg): Set occurs_in_abrnomal_phi as needed.
* tree-ssa-copyprop.c (copyprop_stmt): Do not allow copy
propagations if either argument occurs in an abnormal phi.
(copyprop_phi): Likewise.
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.77
diff -c -3 -p -r1.1.4.77 tree-flow.h
*** tree-flow.h 8 May 2003 20:29:29 -0000 1.1.4.77
--- tree-flow.h 12 May 2003 17:18:10 -0000
*************** struct var_ann_d GTY(())
*** 93,100 ****
/* Used when building root_var structures in tree_ssa_live.[ch]. */
unsigned root_var_processed : 1;
/* Unused bits. */
! unsigned unused : 24;
/* An INDIRECT_REF expression representing all the dereferences of this
pointer. Used to store aliasing information for pointer dereferences
--- 93,103 ----
/* Used when building root_var structures in tree_ssa_live.[ch]. */
unsigned root_var_processed : 1;
+ /* Nonzero if the variable occurs in an abnormal PHI. */
+ unsigned occurs_in_abnormal_phi : 1;
+
/* Unused bits. */
! unsigned unused : 23;
/* An INDIRECT_REF expression representing all the dereferences of this
pointer. Used to store aliasing information for pointer dereferences
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.75
diff -c -3 -p -r1.1.4.75 tree-ssa.c
*** tree-ssa.c 8 May 2003 20:29:30 -0000 1.1.4.75
--- tree-ssa.c 12 May 2003 17:19:20 -0000
*************** static bool var_is_live PARAMS ((tree,
*** 226,232 ****
&& TREE_CODE (SSA_NAME_VAR (RHS)) == INDIRECT_REF) \
/* FIXME. For now, don't propagate pointers if they haven't been \
dereferenced (see update_indirect_ref_vuses). */ \
! && (!POINTER_TYPE_P (TREE_TYPE (RHS)) || indirect_ref (RHS)))
/* Main entry point to the SSA builder. FNDECL is the gimplified function
--- 226,234 ----
&& TREE_CODE (SSA_NAME_VAR (RHS)) == INDIRECT_REF) \
/* FIXME. For now, don't propagate pointers if they haven't been \
dereferenced (see update_indirect_ref_vuses). */ \
! && (!POINTER_TYPE_P (TREE_TYPE (RHS)) || indirect_ref (RHS)) \
! && ! var_ann (SSA_NAME_VAR (LHS))->occurs_in_abnormal_phi \
! && ! var_ann (SSA_NAME_VAR (RHS))->occurs_in_abnormal_phi)
/* Main entry point to the SSA builder. FNDECL is the gimplified function
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.111
diff -c -3 -p -r1.1.4.111 tree-dfa.c
*** tree-dfa.c 8 May 2003 20:29:29 -0000 1.1.4.111
--- tree-dfa.c 12 May 2003 17:19:22 -0000
*************** add_phi_arg (phi, def, e)
*** 937,942 ****
--- 937,951 ----
if (i >= PHI_ARG_CAPACITY (phi))
abort ();
#endif
+
+ /* Copy propagation needs to know what object occur in abnormal
+ PHI nodes. This is a convenient place to record such information. */
+ if (e->flags & EDGE_ABNORMAL)
+ {
+ var_ann (def)->occurs_in_abnormal_phi = 1;
+ var_ann (PHI_RESULT (phi))->occurs_in_abnormal_phi = 1;
+ }
+
PHI_ARG_DEF (phi, i) = def;
PHI_ARG_EDGE (phi, i) = e;
PHI_NUM_ARGS (phi)++;
Index: tree-ssa-copyprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-copyprop.c,v
retrieving revision 1.1.2.1
diff -c -3 -p -r1.1.2.1 tree-ssa-copyprop.c
*** tree-ssa-copyprop.c 1 Mar 2003 00:09:07 -0000 1.1.2.1
--- tree-ssa-copyprop.c 12 May 2003 17:19:22 -0000
*************** copyprop_stmt (stmt)
*** 114,120 ****
tree *use_p = (tree *) VARRAY_GENERIC_PTR (uses, i);
tree orig = get_original (*use_p, &vuse);
! if (orig)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
--- 114,122 ----
tree *use_p = (tree *) VARRAY_GENERIC_PTR (uses, i);
tree orig = get_original (*use_p, &vuse);
! if (orig
! && ! var_ann (SSA_NAME_VAR (*use_p))->occurs_in_abnormal_phi
! && ! var_ann (SSA_NAME_VAR (orig))->occurs_in_abnormal_phi)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
*************** copyprop_phi (phi)
*** 159,165 ****
tree arg = PHI_ARG_DEF (phi, i);
tree orig = get_original (arg, &vuse);
! if (orig)
{
if (dump_file && dump_flags & TDF_DETAILS)
{
--- 161,169 ----
tree arg = PHI_ARG_DEF (phi, i);
tree orig = get_original (arg, &vuse);
! if (orig
! && ! var_ann (SSA_NAME_VAR (arg))->occurs_in_abnormal_phi
! && ! var_ann (SSA_NAME_VAR (orig))->occurs_in_abnormal_phi)
{
if (dump_file && dump_flags & TDF_DETAILS)
{