This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-ssa-sink.c: Don't restrict immediate uses that weconsider.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dberlin at dberlin dot org, law at redhat dot com
- Date: Thu, 07 Apr 2005 10:37:23 -0400 (EDT)
- Subject: [patch] tree-ssa-sink.c: Don't restrict immediate uses that weconsider.
Hi,
Attached is a patch to teach nearest_common_dominator_of_uses not to
restrict the set of immediate uses that we consider.
nearest_common_dominator_of_uses goes through immediate uses to find a
location to sink a statement into. It's important that we consider
all uses so that whatever location we come with dominates all uses.
It's dangerous to have an "if" statement to restrict the set of
immediate uses that we consider like so
if (PHI_ARG_DEF (usestmt, idx) == var)
because the location that we come up with may not dominate all uses.
The patch simply removes the "if" statement.
Having said this, if an SSA_NAME is used in a PHI argument, it must be
used there naked. It cannot possibly occur as a part of an ADDR_EXPR
because that wouldn't be TREE_INVARIANT, so I don't think removal of
this "if" statement matters. However, if we allow an ADDR_EXPR that
is not TREE_INVARIANT in a PHI argument in future, then this would
become a problem (although I don't think such an extension will
actually happen).
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2005-04-07 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-sink.c (nearest_common_dominator_of_uses): Consider
all immediate uses in PHI nodes.
Index: tree-ssa-sink.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-sink.c,v
retrieving revision 1.5
diff -c -d -p -r1.5 tree-ssa-sink.c
*** tree-ssa-sink.c 6 Apr 2005 17:41:11 -0000 1.5
--- tree-ssa-sink.c 6 Apr 2005 17:43:25 -0000
*************** nearest_common_dominator_of_uses (tree s
*** 241,257 ****
if (TREE_CODE (usestmt) == PHI_NODE)
{
int idx = PHI_ARG_INDEX_FROM_USE (use_p);
! if (PHI_ARG_DEF (usestmt, idx) == var)
{
! useblock = PHI_ARG_EDGE (usestmt, idx)->src;
! /* Short circuit. Nothing dominates the entry block. */
! if (useblock == ENTRY_BLOCK_PTR)
! {
! BITMAP_FREE (blocks);
! return NULL;
! }
! bitmap_set_bit (blocks, useblock->index);
}
}
else
{
--- 241,255 ----
if (TREE_CODE (usestmt) == PHI_NODE)
{
int idx = PHI_ARG_INDEX_FROM_USE (use_p);
!
! useblock = PHI_ARG_EDGE (usestmt, idx)->src;
! /* Short circuit. Nothing dominates the entry block. */
! if (useblock == ENTRY_BLOCK_PTR)
{
! BITMAP_FREE (blocks);
! return NULL;
}
+ bitmap_set_bit (blocks, useblock->index);
}
else
{