summaryrefslogtreecommitdiff
path: root/gcc/cfg.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-18 20:15:06 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-18 20:15:06 +0000
commit4d6b11ab420f373787b369905fe1271927ae671c (patch)
treec8155205eea9acda3648c08b1f00c2d20be9270e /gcc/cfg.c
parent2c191cc3f2f5ebcb6054b344f1ae08cfcd8fe516 (diff)
downloadlinaro-gcc-4d6b11ab420f373787b369905fe1271927ae671c.tar.gz
linaro-gcc-4d6b11ab420f373787b369905fe1271927ae671c.tar.bz2
linaro-gcc-4d6b11ab420f373787b369905fe1271927ae671c.zip
* basic-block.h (scale_bbs_frequencies_int,
scale_bbs_frequencies_gcov_type): Declare. * cfg.c (RDIV): New macro. (update_bb_frequency_for_threading): Fix. * basic-block.h (scale_bbs_frequencies_int, scale_bbs_frequencies_gcov_type): New. * cfgloopmanip.c (scale_bbs_frequencies): Kill. (scale_loop_frequencies, duplicate_loop_to_header_edge): Use scale_bbs_frequencies_int. * tree-ssa-loop-ch.c (copy_loop_headers): Fix profiling info. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96700 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r--gcc/cfg.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 03f1ee1f9d2..c0e38f2910f 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -96,6 +96,8 @@ static void free_edge (edge);
/* Indicate the presence of the profile. */
enum profile_status profile_status;
+#define RDIV(X,Y) (((X) + (Y) / 2) / (Y))
+
/* Called once at initialization time. */
void
@@ -933,10 +935,10 @@ update_bb_profile_for_threading (basic_block bb, int edge_frequency,
}
else if (prob != REG_BR_PROB_BASE)
{
- int scale = REG_BR_PROB_BASE / prob;
+ int scale = 65536 * REG_BR_PROB_BASE / prob;
FOR_EACH_EDGE (c, ei, bb->succs)
- c->probability *= scale;
+ c->probability *= scale / 65536;
}
if (bb != taken_edge->src)
@@ -945,3 +947,40 @@ update_bb_profile_for_threading (basic_block bb, int edge_frequency,
if (taken_edge->count < 0)
taken_edge->count = 0;
}
+
+/* Multiply all frequencies of basic blocks in array BBS of length NBBS
+ by NUM/DEN, in int arithmetic. May lose some accuracy. */
+void
+scale_bbs_frequencies_int (basic_block *bbs, int nbbs, int num, int den)
+{
+ int i;
+ edge e;
+ for (i = 0; i < nbbs; i++)
+ {
+ edge_iterator ei;
+ bbs[i]->frequency = (bbs[i]->frequency * num) / den;
+ bbs[i]->count = RDIV (bbs[i]->count * num, den);
+ FOR_EACH_EDGE (e, ei, bbs[i]->succs)
+ e->count = (e->count * num) /den;
+ }
+}
+
+/* Multiply all frequencies of basic blocks in array BBS of length NBBS
+ by NUM/DEN, in gcov_type arithmetic. More accurate than previous
+ function but considerably slower. */
+void
+scale_bbs_frequencies_gcov_type (basic_block *bbs, int nbbs, gcov_type num,
+ gcov_type den)
+{
+ int i;
+ edge e;
+
+ for (i = 0; i < nbbs; i++)
+ {
+ edge_iterator ei;
+ bbs[i]->frequency = (bbs[i]->frequency * num) / den;
+ bbs[i]->count = RDIV (bbs[i]->count * num, den);
+ FOR_EACH_EDGE (e, ei, bbs[i]->succs)
+ e->count = (e->count * num) /den;
+ }
+}