[phc-internals] [phc commit] r1832 - in branches/dataflow/src:
generated generated_src optimize optimize/ssa
codesite-noreply at google.com
codesite-noreply at google.com
Tue Oct 28 20:41:10 GMT 2008
Author: paul.biggar
Date: Tue Oct 28 13:40:34 2008
New Revision: 1832
Modified:
branches/dataflow/src/generated/MIR.cpp
branches/dataflow/src/generated/MIR.h
branches/dataflow/src/generated_src/mir.tea
branches/dataflow/src/optimize/Def_use.cpp
branches/dataflow/src/optimize/ssa/HSSA.cpp
Log:
when going out of SSA form, only create assignments for phi nodes if the
phi arg is a literal, and just drop ssa indices.
Modified: branches/dataflow/src/generated/MIR.cpp
==============================================================================
--- branches/dataflow/src/generated/MIR.cpp (original)
+++ branches/dataflow/src/generated/MIR.cpp Tue Oct 28 13:40:34 2008
@@ -10090,6 +10090,15 @@
}
}
+void VARIABLE_NAME::drop_ssa_index()
+{
+ {
+ assert (this->in_ssa);
+ in_ssa = false;
+ this->version = 0;
+ }
+}
+
VARIABLE_NAME* VARIABLE_NAME::clone()
{
{
Modified: branches/dataflow/src/generated/MIR.h
==============================================================================
--- branches/dataflow/src/generated/MIR.h (original)
+++ branches/dataflow/src/generated/MIR.h Tue Oct 28 13:40:34 2008
@@ -2704,6 +2704,7 @@
VARIABLE_NAME(String* name);
VARIABLE_NAME(const char* name);
void convert_to_ssa_name(int version);
+ void drop_ssa_index();
VARIABLE_NAME* clone();
void set_version(int version);
bool operator<(MIR ::VARIABLE_NAME& other);
Modified: branches/dataflow/src/generated_src/mir.tea
==============================================================================
--- branches/dataflow/src/generated_src/mir.tea (original)
+++ branches/dataflow/src/generated_src/mir.tea Tue Oct 28 13:40:34 2008
@@ -478,6 +478,13 @@
this->is_virtual = false;
}
+ void drop_ssa_index ()
+ {
+ assert (this->in_ssa);
+ in_ssa = false;
+ this->version = 0;
+ }
+
VARIABLE_NAME* clone ()
{
String* value = new String(*this->value);
Modified: branches/dataflow/src/optimize/Def_use.cpp
==============================================================================
--- branches/dataflow/src/optimize/Def_use.cpp (original)
+++ branches/dataflow/src/optimize/Def_use.cpp Tue Oct 28 13:40:34 2008
@@ -152,7 +152,12 @@
}
-
+/*
+ * Calculate the def-use web
+ * TODO: this probably needs to be integrated with alias-analysis, or at
+ * least with mu/chi calculation. Its not enough to say a def creates a
load
+ * of may-defs.
+ */
void
Def_use_web::add_use (MIR::Rvalue* def, SSA_op* use)
{
Modified: branches/dataflow/src/optimize/ssa/HSSA.cpp
==============================================================================
--- branches/dataflow/src/optimize/ssa/HSSA.cpp (original)
+++ branches/dataflow/src/optimize/ssa/HSSA.cpp Tue Oct 28 13:40:34 2008
@@ -134,11 +134,36 @@
bb->remove_mu_nodes ();
bb->remove_virtual_phis ();
+ // There are two problems when coming out of SSA form:
+ // 1.) variable-variables: i_0 is not the same as i
+ // 2.) CHI nodes update variable indices, but when you drop the chi
+ // nodes, you lose the relationship between them. Renumbering is
+ // possible, I suppose, but not as good as:
+ //
+ // The solution is to drop the indices when coming out of SSA form.
+ // (Warning, this could hide bugs unfortunately). The only real problem
+ // is to make sure that variables with overlapping live ranges are not
+ // created. This could happen in copy-propagation, value numbering, or
+ // PRE. I suspect the latter two can be avoided by using the HSSA
+ // algorithms. For copy-propagation, I'll just have to be careful.
+
+ // TODO: Add a check that there aren't overlapping live ranges.
foreach (VARIABLE_NAME* phi_lhs, *bb->get_phi_lhss ())
{
BB_list* preds = bb->get_predecessors ();
foreach (Rvalue* rval, *bb->get_phi_args (phi_lhs))
{
+ if (isa<VARIABLE_NAME> (rval))
+ {
+ VARIABLE_NAME* var = dyc<VARIABLE_NAME> (rval);
+
+ // We've dropped the indices, so make sure the varaibles are
+ // equal (if they arent, perhaps if we've added copy
+ // propagation, we should add an assignment).
+ assert (*var->value == *phi_lhs->value);
+ continue;
+ }
+
Assign_var* copy = new Assign_var (
phi_lhs->clone (),
false,
@@ -157,7 +182,21 @@
}
}
bb->remove_phi_nodes ();
+
}
+
+
+ // Drop variable indices
+ rebuild_ssa_form (); // we only care about DUW
+ foreach (Basic_block* bb, *cfg->get_all_bbs ())
+ {
+ foreach (VARIABLE_NAME* var, *cfg->duw->get_nonphi_uses (bb))
+ var->drop_ssa_index();
+
+ foreach (VARIABLE_NAME* var, *cfg->duw->get_nonphi_defs (bb))
+ var->drop_ssa_index();
+ }
+
More information about the phc-internals
mailing list