Commit a08b2604 by Jan Hubicka Committed by Jan Hubicka

flow.c (mark_set_1): Use REG_FREQ_FROM_BB.

	* flow.c (mark_set_1): Use REG_FREQ_FROM_BB.
	(attempt_auto_inc): LIkewise.
	(mark_used_reg): Likewise.
	(try_pre_increment_1): Likewise.
	* regclass.c (regclass): Likewise.
	* global.c (allocno_compare): Update comment; change scaling factor.
	* local-alloc.c (QTY_CMP_PRI): Likewise.
	* regs.h (REG_FREQ_FROM_BB): New.
	(REG_FREQ_MAX): Likewise.

From-SVN: r44483
parent e5b3941e
Mon Jul 30 21:54:53 CEST 2001 Jan Hubicka <jh@suse.cz>
* flow.c (mark_set_1): Use REG_FREQ_FROM_BB.
(attempt_auto_inc): LIkewise.
(mark_used_reg): Likewise.
(try_pre_increment_1): Likewise.
* regclass.c (regclass): Likewise.
* global.c (allocno_compare): Update comment; change scaling factor.
* local-alloc.c (QTY_CMP_PRI): Likewise.
* regs.h (REG_FREQ_FROM_BB): New.
(REG_FREQ_MAX): Likewise.
2001-07-30 H.J. Lu <hjl@gnu.org>
* config/mips/linux.h (CPLUSPLUS_CPP_SPEC): Add
......
......@@ -6220,8 +6220,7 @@ mark_set_1 (pbi, code, reg, cond, insn, flags)
register twice if it is modified, but that is correct. */
REG_N_SETS (i) += 1;
REG_N_REFS (i) += 1;
REG_FREQ (i) += (optimize_size || !pbi->bb->frequency
? 1 : pbi->bb->frequency);
REG_FREQ (i) += REG_FREQ_FROM_BB (pbi->bb);
/* The insns where a reg is live are normally counted
elsewhere, but we want the count to include the insn
......@@ -6888,8 +6887,7 @@ attempt_auto_inc (pbi, inc, insn, mem, incr, incr_reg)
/* Count an extra reference to the reg. When a reg is
incremented, spilling it is worse, so we want to make
that less likely. */
REG_FREQ (regno) += (optimize_size || !pbi->bb->frequency
? 1 : pbi->bb->frequency);
REG_FREQ (regno) += REG_FREQ_FROM_BB (pbi->bb);
/* Count the increment as a setting of the register,
even though it isn't a SET in rtl. */
......@@ -7054,8 +7052,7 @@ mark_used_reg (pbi, reg, cond, insn)
REG_BASIC_BLOCK (regno_first) = REG_BLOCK_GLOBAL;
/* Count (weighted) number of uses of each reg. */
REG_FREQ (regno_first)
+= (optimize_size || !pbi->bb->frequency ? 1 : pbi->bb->frequency);
REG_FREQ (regno_first) += REG_FREQ_FROM_BB (pbi->bb);
REG_N_REFS (regno_first)++;
}
}
......@@ -7477,8 +7474,7 @@ try_pre_increment_1 (pbi, insn)
so we want to make that less likely. */
if (regno >= FIRST_PSEUDO_REGISTER)
{
REG_FREQ (regno) += (optimize_size || !pbi->bb->frequency
? 1 : pbi->bb->frequency);
REG_FREQ (regno) += REG_FREQ_FROM_BB (pbi->bb);
REG_N_SETS (regno)++;
}
......
......@@ -611,16 +611,17 @@ allocno_compare (v1p, v2p)
int v1 = *(const int *)v1p, v2 = *(const int *)v2p;
/* Note that the quotient will never be bigger than
the value of floor_log2 times the maximum number of
times a register can occur in one insn (surely less than 100).
Multiplying this by 10000 can't overflow. */
times a register can occur in one insn (surely less than 100)
weighted by the frequency (maximally REG_FREQ_MAX).
Multiplying this by 10000/REG_FREQ_MAX can't overflow. */
register int pri1
= (((double) (floor_log2 (allocno[v1].n_refs) * allocno[v1].freq)
/ allocno[v1].live_length)
* 10000 * allocno[v1].size);
* (10000 / REG_FREQ_MAX) * allocno[v1].size);
register int pri2
= (((double) (floor_log2 (allocno[v2].n_refs) * allocno[v2].freq)
/ allocno[v2].live_length)
* 10000 * allocno[v2].size);
* (10000 / REG_FREQ_MAX) * allocno[v2].size);
if (pri2 - pri1)
return pri2 - pri1;
......
......@@ -1698,13 +1698,14 @@ block_alloc (b)
/* Note that the quotient will never be bigger than
the value of floor_log2 times the maximum number of
times a register can occur in one insn (surely less than 100).
Multiplying this by 10000 can't overflow.
times a register can occur in one insn (surely less than 100)
weighted by frequency (max REG_FREQ_MAX).
Multiplying this by 10000/REG_FREQ_MAX can't overflow.
QTY_CMP_PRI is also used by qty_sugg_compare. */
#define QTY_CMP_PRI(q) \
((int) (((double) (floor_log2 (qty[q].n_refs) * qty[q].freq * qty[q].size) \
/ (qty[q].death - qty[q].birth)) * 10000))
/ (qty[q].death - qty[q].birth)) * (10000 / REG_FREQ_MAX)))
static int
qty_compare (q1, q2)
......
......@@ -1233,7 +1233,7 @@ regclass (f, nregs, dump)
if (!optimize)
{
frequency = 1;
frequency = REG_FREQ_MAX;
for (insn = f; insn; insn = NEXT_INSN (insn))
insn = scan_one_insn (insn, pass);
}
......@@ -1246,10 +1246,7 @@ regclass (f, nregs, dump)
times more than insns outside a loop. This is much more
aggressive than the assumptions made elsewhere and is being
tried as an experiment. */
if (optimize_size)
frequency = 1;
else
frequency = bb->frequency ? bb->frequency : 1;
frequency = REG_FREQ_FROM_BB (bb);
for (insn = bb->head; ; insn = NEXT_INSN (insn))
{
insn = scan_one_insn (insn, pass);
......
......@@ -86,6 +86,24 @@ extern varray_type reg_n_info;
#define REG_FREQ(N) (VARRAY_REG (reg_n_info, N)->freq)
/* The weights for each insn varries from 0 to REG_FREQ_BASE.
This constant does not need to be high, as in infrequently executed
regions we want to count instructions equivalently to optimize for
size instead of speed. */
#define REG_FREQ_MAX 1000
/* Compute register frequency from the BB frequency. When optimizing for size,
or profile driven feedback is available and the function is never executed,
frequency is always equivalent. Otherwise rescale the basic block
frequency. */
#define REG_FREQ_FROM_BB(bb) (optimize_size \
|| (flag_branch_probabilities \
&& !ENTRY_BLOCK_PTR->count) \
? REG_FREQ_MAX \
: ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
? ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
: 1)
/* Indexed by n, gives number of times (REG n) is set.
??? both regscan and flow allocate space for this. We should settle
on just copy. */
......
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