aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/tree-dfa.c33
-rw-r--r--gcc/tree-flow.h2
-rw-r--r--gcc/tree-ssa-alias.c114
4 files changed, 93 insertions, 70 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ad09b586..7c4c706 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2007-10-25 Richard Guenther <rguenther@suse.de>
+
+ * tree-flow.h (mem_sym_stats): Remove.
+ (dump_mem_sym_stats_for_var): Declare.
+ * tree-dfa.c (dump_variable): Call dump_mem_sym_stats_for_var.
+ (mem_sym_stats): Move ...
+ * tree-ssa-alias.c (mem_sym_stats): ... here and make it static.
+ (mem_sym_score): Rename from ...
+ (pscore): ... this. Remove.
+ (dump_mem_sym_stats_for_var): New function. Dump the score, but
+ not the frequencies.
+ (compare_mp_info_entries): Make sort stable by disambiguating
+ on DECL_UID.
+
2007-10-25 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/33866
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index f7f4243..79f3b87 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -345,16 +345,7 @@ dump_variable (FILE *file, tree var)
if (TREE_THIS_VOLATILE (var))
fprintf (file, ", is volatile");
- if (mem_sym_stats (cfun, var))
- {
- mem_sym_stats_t stats = mem_sym_stats (cfun, var);
- fprintf (file, ", direct reads: %ld", stats->num_direct_reads);
- fprintf (file, ", direct writes: %ld", stats->num_direct_writes);
- fprintf (file, ", indirect reads: %ld", stats->num_indirect_reads);
- fprintf (file, ", indirect writes: %ld", stats->num_indirect_writes);
- fprintf (file, ", read frequency: %ld", stats->frequency_reads);
- fprintf (file, ", write frequency: %ld", stats->frequency_writes);
- }
+ dump_mem_sym_stats_for_var (file, var);
if (is_call_clobbered (var))
{
@@ -1010,25 +1001,3 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
return exp;
}
-
-/* Return memory reference statistics for variable VAR in function FN.
- This is computed by alias analysis, but it is not kept
- incrementally up-to-date. So, these stats are only accurate if
- pass_may_alias has been run recently. If no alias information
- exists, this function returns NULL. */
-
-mem_sym_stats_t
-mem_sym_stats (struct function *fn, tree var)
-{
- void **slot;
- struct pointer_map_t *stats_map = gimple_mem_ref_stats (fn)->mem_sym_stats;
-
- if (stats_map == NULL)
- return NULL;
-
- slot = pointer_map_contains (stats_map, var);
- if (slot == NULL)
- return NULL;
-
- return (mem_sym_stats_t) *slot;
-}
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index e07e2b2..1d6808b 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -810,7 +810,6 @@ extern void find_new_referenced_vars (tree *);
extern tree make_rename_temp (tree, const char *);
extern void set_default_def (tree, tree);
extern tree gimple_default_def (struct function *, tree);
-extern struct mem_sym_stats_d *mem_sym_stats (struct function *, tree);
/* In tree-phinodes.c */
extern void reserve_phi_args_for_new_edge (basic_block);
@@ -856,6 +855,7 @@ extern void dump_mem_ref_stats (FILE *);
extern void debug_mem_ref_stats (void);
extern void debug_memory_partitions (void);
extern void debug_mem_sym_stats (tree var);
+extern void dump_mem_sym_stats_for_var (FILE *, tree);
extern void debug_all_mem_sym_stats (void);
/* Call-back function for walk_use_def_chains(). At each reaching
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 1ff3821..e96f0ef 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -242,6 +242,29 @@ get_mem_sym_stats_for (tree var)
}
+/* Return memory reference statistics for variable VAR in function FN.
+ This is computed by alias analysis, but it is not kept
+ incrementally up-to-date. So, these stats are only accurate if
+ pass_may_alias has been run recently. If no alias information
+ exists, this function returns NULL. */
+
+static mem_sym_stats_t
+mem_sym_stats (struct function *fn, tree var)
+{
+ void **slot;
+ struct pointer_map_t *stats_map = gimple_mem_ref_stats (fn)->mem_sym_stats;
+
+ if (stats_map == NULL)
+ return NULL;
+
+ slot = pointer_map_contains (stats_map, var);
+ if (slot == NULL)
+ return NULL;
+
+ return (mem_sym_stats_t) *slot;
+}
+
+
/* Set MPT to be the memory partition associated with symbol SYM. */
static inline void
@@ -774,6 +797,40 @@ count_mem_refs (long *num_vuses_p, long *num_vdefs_p,
}
+/* The list is sorted by increasing partitioning score (PSCORE).
+ This score is computed such that symbols with high scores are
+ those that are least likely to be partitioned. Given a symbol
+ MP->VAR, PSCORE(S) is the result of the following weighted sum
+
+ PSCORE(S) = FW * 64 + FR * 32
+ + DW * 16 + DR * 8
+ + IW * 4 + IR * 2
+ + NO_ALIAS
+
+ where
+
+ FW Execution frequency of writes to S
+ FR Execution frequency of reads from S
+ DW Number of direct writes to S
+ DR Number of direct reads from S
+ IW Number of indirect writes to S
+ IR Number of indirect reads from S
+ NO_ALIAS State of the NO_ALIAS* flags
+
+ The basic idea here is that symbols that are frequently
+ written-to in hot paths of the code are the last to be considered
+ for partitioning. */
+
+static inline long
+mem_sym_score (mem_sym_stats_t mp)
+{
+ return mp->frequency_writes * 64 + mp->frequency_reads * 32
+ + mp->num_direct_writes * 16 + mp->num_direct_reads * 8
+ + mp->num_indirect_writes * 4 + mp->num_indirect_reads * 2
+ + var_ann (mp->var)->noalias_state;
+}
+
+
/* Dump memory reference stats for function CFUN to FILE. */
void
@@ -874,6 +931,23 @@ debug_mem_sym_stats (tree var)
dump_mem_sym_stats (stderr, var);
}
+/* Dump memory reference stats for variable VAR to FILE. For use
+ of tree-dfa.c:dump_variable. */
+
+void
+dump_mem_sym_stats_for_var (FILE *file, tree var)
+{
+ mem_sym_stats_t stats = mem_sym_stats (cfun, var);
+
+ if (stats == NULL)
+ return;
+
+ fprintf (file, ", score: %ld", mem_sym_score (stats));
+ fprintf (file, ", direct reads: %ld", stats->num_direct_reads);
+ fprintf (file, ", direct writes: %ld", stats->num_direct_writes);
+ fprintf (file, ", indirect reads: %ld", stats->num_indirect_reads);
+ fprintf (file, ", indirect writes: %ld", stats->num_indirect_writes);
+}
/* Dump memory reference stats for all memory symbols to FILE. */
@@ -950,40 +1024,6 @@ update_mem_sym_stats_from_stmt (tree var, tree stmt, long num_direct_reads,
}
-/* The list is sorted by increasing partitioning score (PSCORE).
- This score is computed such that symbols with high scores are
- those that are least likely to be partitioned. Given a symbol
- MP->VAR, PSCORE(S) is the result of the following weighted sum
-
- PSCORE(S) = FW * 64 + FR * 32
- + DW * 16 + DR * 8
- + IW * 4 + IR * 2
- + NO_ALIAS
-
- where
-
- FW Execution frequency of writes to S
- FR Execution frequency of reads from S
- DW Number of direct writes to S
- DR Number of direct reads from S
- IW Number of indirect writes to S
- IR Number of indirect reads from S
- NO_ALIAS State of the NO_ALIAS* flags
-
- The basic idea here is that symbols that are frequently
- written-to in hot paths of the code are the last to be considered
- for partitioning. */
-
-static inline long
-pscore (mem_sym_stats_t mp)
-{
- return mp->frequency_writes * 64 + mp->frequency_reads * 32
- + mp->num_direct_writes * 16 + mp->num_direct_reads * 8
- + mp->num_indirect_writes * 4 + mp->num_indirect_reads * 2
- + var_ann (mp->var)->noalias_state;
-}
-
-
/* Given two MP_INFO entries MP1 and MP2, return -1 if MP1->VAR should
be partitioned before MP2->VAR, 0 if they are the same or 1 if
MP1->VAR should be partitioned after MP2->VAR. */
@@ -991,15 +1031,15 @@ pscore (mem_sym_stats_t mp)
static inline int
compare_mp_info_entries (mem_sym_stats_t mp1, mem_sym_stats_t mp2)
{
- long pscore1 = pscore (mp1);
- long pscore2 = pscore (mp2);
+ long pscore1 = mem_sym_score (mp1);
+ long pscore2 = mem_sym_score (mp2);
if (pscore1 < pscore2)
return -1;
else if (pscore1 > pscore2)
return 1;
else
- return 0;
+ return DECL_UID (mp1->var) - DECL_UID (mp2->var);
}