On Wed, 2004-10-20 at 16:38, Daniel Berlin wrote:
On Oct 20, 2004, at 4:32 PM, Diego Novillo wrote:
On Wed, 2004-10-20 at 14:20, Daniel Berlin wrote:
1. Do a quick propagation pass in DCE to make sure def-def phis that
are used in necessary statements don't die. (at that point, plain
def-def renaming will work)
2. Mark the must-def operand as necessary if it's a phi, and the
only
immediate use of the phi is in the must-def operand (I'm assuming it
could appear in a may-def or vuse somewhere else, in which case it's
necessary).
3. Use the full renamer, which will simply put the phi back after
DCE
removes it.
4. If the RHS of a V_MUST_DEF is a PHI node, mark it necessary?
That's #1, actually.
Before remove_stmts, i meant you do this:
FOR EACH MUSTDEF:
If RHS is a phi node and marked unnecessary:
add phi node to worklist.
Until worklist is empty:
pop phi off worklist. Mark as necessary.
For each phi node argument that is a phi node marked unnecessary, add
to worklist.
This also catches the mutually recursive phis like:
a_1 = phi <a_2, <a_something>>
a_2 = phi <a_4, a_1>
a_4 = must_def <a_2>
You actually have to worklist it because those phi nodes may use phi
nodes, and you have to mark those phi nodes as necessary as well.
:)
Hmm? I was thinking along the lines of
--- tree-ssa-dce.c 13 Oct 2004 16:04:17 -0000 2.18.2.2
+++ tree-ssa-dce.c 20 Oct 2004 20:47:50 -0000
@@ -487,6 +487,9 @@ find_obviously_necessary_stmts (struct e
{
tree stmt = bsi_stmt (i);
NECESSARY (stmt) = 0;
+ FOR_EACH_SSA_TREE_OPERAND (vdef, stmt, i, SSA_OP_VMUSTDEF)
+ if (TREE_CODE (SSA_NAME_DEF_STMT (vdef)) == PHI_NODE)
+ mark_stmt_necessary (SSA_NAME_DEF_STMT (vdef));
mark_stmt_if_obviously_necessary (stmt, el != NULL);
Or am I missing something obvious?