This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Better estimations of costs in outof-ssa
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 Jul 2005 09:22:27 +0200
- Subject: Better estimations of costs in outof-ssa
Hi,
outofssa is pretty simple minded about cost estimation of copy instructions it
inserts. In testcase I was looking at (bresenham line drawing loop) it opted
to split critical edge within loop instead of adding copy off the loop. This
patch makes the individual costs to be weighted by profile. This has (very
small) positive impact to SPEC too (roughly 4 points, but close to noise).
Bootstrapped/regtested i686-pc-gnu-linux, OK?
Honza
2005-07-28 Jan Hubicka <jh@suse.cz>
* tree-outof-ssa.c (coalesce_ssa_name, coalesce_vars): Use
profile for computing costs.
* tree-ssa-live.c (build_tree_conflict_graph): Likewise.
Index: tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-outof-ssa.c,v
retrieving revision 2.64
diff -c -3 -p -r2.64 tree-outof-ssa.c
*** tree-outof-ssa.c 25 Jun 2005 02:01:28 -0000 2.64
--- tree-outof-ssa.c 25 Jul 2005 17:29:08 -0000
*************** coalesce_ssa_name (var_map map, int flag
*** 729,735 ****
continue;
p2 = var_to_partition (map, PHI_ARG_DEF (phi, x));
if (p2 != NO_PARTITION)
! add_coalesce (cl, p, p2, 1);
}
}
}
--- 729,748 ----
continue;
p2 = var_to_partition (map, PHI_ARG_DEF (phi, x));
if (p2 != NO_PARTITION)
! {
! /* Base costs on BB frequencies bounded by 1. */
! int cost = EDGE_FREQUENCY (PHI_ARG_EDGE (phi, x));
!
! if (!cost)
! cost = 1;
! if (optimize_size || !maybe_hot_bb_p (bb))
! cost = 1;
! /* Inserting copy on critical edge is more costy
! than inserting it elsewhere. */
! if (EDGE_CRITICAL_P (PHI_ARG_EDGE (phi, x)))
! cost *= 2;
! add_coalesce (cl, p, p2, cost);
! }
}
}
}
*************** coalesce_vars (var_map map, tree_live_in
*** 1097,1103 ****
if (p2 == (unsigned)NO_PARTITION)
continue;
if (p != p2)
! add_coalesce (cl, p, p2, 1);
}
}
}
--- 1110,1129 ----
if (p2 == (unsigned)NO_PARTITION)
continue;
if (p != p2)
! {
! /* Base costs on BB frequencies bounded by 1. */
! int cost = EDGE_FREQUENCY (PHI_ARG_EDGE (phi, x));
!
! if (!cost)
! cost = 1;
! if (optimize_size || !maybe_hot_bb_p (bb))
! cost = 1;
! /* Inserting copy on critical edge is more costy
! than inserting it elsewhere. */
! if (EDGE_CRITICAL_P (PHI_ARG_EDGE (phi, x)))
! cost *= 2;
! add_coalesce (cl, p, p2, cost);
! }
}
}
}
Index: tree-ssa-live.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-live.c,v
retrieving revision 2.41
diff -c -3 -p -r2.41 tree-ssa-live.c
*** tree-ssa-live.c 30 Jun 2005 22:18:33 -0000 2.41
--- tree-ssa-live.c 25 Jul 2005 17:29:09 -0000
*************** build_tree_conflict_graph (tree_live_inf
*** 1383,1389 ****
if (bit)
bitmap_set_bit (live, p2);
if (cl)
! add_coalesce (cl, p1, p2, 1);
set_if_valid (map, live, rhs);
}
}
--- 1383,1397 ----
if (bit)
bitmap_set_bit (live, p2);
if (cl)
! {
! /* Base costs on BB frequencies bounded by 1. */
! int cost = bb->frequency;
! if (!cost)
! cost = 1;
! if (optimize_size || !maybe_hot_bb_p (bb))
! cost = 1;
! add_coalesce (cl, p1, p2, cost);
! }
set_if_valid (map, live, rhs);
}
}