This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Speed up dominator and out-of-ssa passes
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Apr 2004 13:47:03 -0600
- Subject: [tree-ssa] Speed up dominator and out-of-ssa passes
- Reply-to: law at redhat dot com
This is something I noticed while evaluating the compile-time performance
of the incremental SSA updating scheme I've been working on.
When the dominator optimizer threads a jump, it takes a set of variables out
of SSA form (and the time is charged to the dominator optimizer).
This out-of-ssa code has a rather expensive sanity check which walks through
all the PHI arguments to see if any of them are assigned to a partition
when the PHI result is not assigned to a partition (eliminate_build). The
problem is the placement of that code resulted in us examining each PHI
multiple times.
Moving the code to a better location so that each PHI is only sanity
checked once is about a .3% improvement across the components of cc1.
Nothing radical, but nice for simply moving a hunk of code to a better
location within the compiler. Note this is inside an ENABLE_CHECKING
block, so this only improves ENABLE_CHECKING compile times.
[ You might ask if this code is relevant if we have a true incremental
SSA updating scheme. The answer is no, it would not be relevant.
However, I'm pretty confident we're still a long way from being
able to completely eliminate this code. There's a number of very
nasty problems that have to be solved before we can have a real
incremental update of the SSA graph in response to jump threading. ]
* tree-outof-ssa.c (eliminate_build): Move code which verifies
that all of a PHI's arguments do not have a partition if the
result does not have a partition from here to...
(rewrite_trees): Here.
Index: tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-outof-ssa.c,v
retrieving revision 1.1.2.4
diff -c -p -r1.1.2.4 tree-outof-ssa.c
*** tree-outof-ssa.c 16 Apr 2004 17:13:36 -0000 1.1.2.4
--- tree-outof-ssa.c 30 Apr 2004 19:44:39 -0000
*************** eliminate_build (elim_graph g, basic_blo
*** 349,374 ****
/* Ignore results which are not in partitions. */
if (T0 == NULL_TREE)
! {
! #ifdef ENABLE_CHECKING
! /* There should be no arguments of this PHI which are in
! the partition list, or we get incorrect results. */
! for (pi = 0; pi < PHI_NUM_ARGS (phi); pi++)
! {
! tree arg = PHI_ARG_DEF (phi, pi);
! if (TREE_CODE (arg) == SSA_NAME
! && var_to_partition (g->map, arg) != NO_PARTITION)
! {
! fprintf (stderr, "Argument of PHI is in a partition :(");
! print_generic_expr (stderr, arg, TDF_SLIM);
! fprintf (stderr, "), but the result is not :");
! print_generic_stmt (stderr, phi, TDF_SLIM);
! abort();
! }
! }
! #endif
! continue;
! }
if (PHI_ARG_EDGE (phi, i) == g->e)
Ti = PHI_ARG_DEF (phi, i);
--- 349,355 ----
/* Ignore results which are not in partitions. */
if (T0 == NULL_TREE)
! continue;
if (PHI_ARG_EDGE (phi, i) == g->e)
Ti = PHI_ARG_DEF (phi, i);
*************** rewrite_trees (var_map map, tree *values
*** 1796,1801 ****
--- 1777,1817 ----
edge e;
tree phi;
bool changed;
+
+ #ifdef ENABLE_CHECKING
+ /* Search for PHIs where the destination has no partition, but one
+ or more arguments has a partition. This should not happen and can
+ create incorrect code. */
+ FOR_EACH_BB (bb)
+ {
+ tree phi;
+
+ for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
+ {
+ tree T0 = var_to_partition_to_var (map, PHI_RESULT (phi));
+
+ if (T0 == NULL_TREE)
+ {
+ int i;
+
+ for (i = 0; i < PHI_NUM_ARGS (phi); i++)
+ {
+ tree arg = PHI_ARG_DEF (phi, i);
+
+ if (TREE_CODE (arg) == SSA_NAME
+ && var_to_partition (map, arg) != NO_PARTITION)
+ {
+ fprintf (stderr, "Argument of PHI is in a partition :(");
+ print_generic_expr (stderr, arg, TDF_SLIM);
+ fprintf (stderr, "), but the result is not :");
+ print_generic_stmt (stderr, phi, TDF_SLIM);
+ abort();
+ }
+ }
+ }
+ }
+ }
+ #endif
/* Replace PHI nodes with any required copies. */
g = new_elim_graph (map->num_partitions);