Commit 692dc070 by Jan Hubicka Committed by Jan Hubicka

cfgloopanal.c: Include sreal.h

	* cfgloopanal.c: Include sreal.h
	(average_num_loop_insns): Use counts and sreal for accounting.

From-SVN: r254807
parent e7b655e8
2017-11-14 Jan Hubicka <hubicka@ucw.cz> 2017-11-14 Jan Hubicka <hubicka@ucw.cz>
* cfgloopanal.c: Include sreal.h
(average_num_loop_insns): Use counts and sreal for accounting.
2017-11-14 Jan Hubicka <hubicka@ucw.cz>
* cfgloopmanip.c (duplicate_loop_to_header_edge): Cleanup profile * cfgloopmanip.c (duplicate_loop_to_header_edge): Cleanup profile
manipulation. manipulation.
...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "expr.h" #include "expr.h"
#include "graphds.h" #include "graphds.h"
#include "params.h" #include "params.h"
#include "sreal.h"
struct target_cfgloop default_target_cfgloop; struct target_cfgloop default_target_cfgloop;
#if SWITCHABLE_TARGET #if SWITCHABLE_TARGET
...@@ -199,7 +200,8 @@ int ...@@ -199,7 +200,8 @@ int
average_num_loop_insns (const struct loop *loop) average_num_loop_insns (const struct loop *loop)
{ {
basic_block *bbs, bb; basic_block *bbs, bb;
unsigned i, binsns, ninsns, ratio; unsigned i, binsns;
sreal ninsns;
rtx_insn *insn; rtx_insn *insn;
ninsns = 0; ninsns = 0;
...@@ -213,19 +215,18 @@ average_num_loop_insns (const struct loop *loop) ...@@ -213,19 +215,18 @@ average_num_loop_insns (const struct loop *loop)
if (NONDEBUG_INSN_P (insn)) if (NONDEBUG_INSN_P (insn))
binsns++; binsns++;
ratio = loop->header->count.to_frequency (cfun) == 0 ninsns += (sreal)binsns * bb->count.to_sreal_scale (loop->header->count);
? BB_FREQ_MAX /* Avoid overflows. */
: (bb->count.to_frequency (cfun) * BB_FREQ_MAX) if (ninsns > 1000000)
/ loop->header->count.to_frequency (cfun); return 100000;
ninsns += binsns * ratio;
} }
free (bbs); free (bbs);
ninsns /= BB_FREQ_MAX; int64_t ret = ninsns.to_int ();
if (!ninsns) if (!ret)
ninsns = 1; /* To avoid division by zero. */ ret = 1; /* To avoid division by zero. */
return ninsns; return ret;
} }
/* Returns expected number of iterations of LOOP, according to /* Returns expected number of iterations of LOOP, according to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment