Commit ac5e69da by Josef Zlomek Committed by Josef Zlomek

Makefile.in (sreal.o): Added.

	* Makefile.in (sreal.o): Added.
	(predict.o): Depends on sreal.h instead of real.h.
	* sreal.c: New file.
	* sreal.h: New file.
	* predict.c: Use sreal.c instead of real.c.

From-SVN: r62630
parent 637df4f4
2003-02-10 Josef Zlomek <zlomekj@suse.cz>
* Makefile.in (sreal.o): Added.
(predict.o): Depends on sreal.h instead of real.h.
* sreal.c: New file.
* sreal.h: New file.
* predict.c: Use sreal.c instead of real.c.
2003-02-10 Nick Clifton <nickc@redhat.com> 2003-02-10 Nick Clifton <nickc@redhat.com>
* Contributed support for the Cirrus EP9312 "Maverick" * Contributed support for the Cirrus EP9312 "Maverick"
......
...@@ -782,7 +782,7 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \ ...@@ -782,7 +782,7 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \
real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \ real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \
reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \ reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \
sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o \ sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o \
sibcall.o simplify-rtx.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \ sibcall.o simplify-rtx.o sreal.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \
stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \ stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \
tree-inline.o unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \ tree-inline.o unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \
alloc-pool.o et-forest.o \ alloc-pool.o et-forest.o \
...@@ -1685,9 +1685,10 @@ recog.o : recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) function. ...@@ -1685,9 +1685,10 @@ recog.o : recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) function.
reg-stack.o : reg-stack.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \ reg-stack.o : reg-stack.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
$(RECOG_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h toplev.h reload.h \ $(RECOG_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h toplev.h reload.h \
varray.h function.h $(TM_P_H) $(GGC_H) gt-reg-stack.h varray.h function.h $(TM_P_H) $(GGC_H) gt-reg-stack.h
sreal.o: sreal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) sreal.h
predict.o: predict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \ predict.o: predict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
flags.h insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h \ flags.h insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h \
$(RECOG_H) function.h except.h $(EXPR_H) $(TM_P_H) $(PREDICT_H) real.h \ $(RECOG_H) function.h except.h $(EXPR_H) $(TM_P_H) $(PREDICT_H) sreal.h \
$(PARAMS_H) $(TARGET_H) cfgloop.h $(PARAMS_H) $(TARGET_H) cfgloop.h
lists.o: lists.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(RTL_H) $(GGC_H) lists.o: lists.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(RTL_H) $(GGC_H)
bb-reorder.o : bb-reorder.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ bb-reorder.o : bb-reorder.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
......
...@@ -48,7 +48,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -48,7 +48,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "expr.h" #include "expr.h"
#include "predict.h" #include "predict.h"
#include "profile.h" #include "profile.h"
#include "real.h" #include "sreal.h"
#include "params.h" #include "params.h"
#include "target.h" #include "target.h"
#include "loop.h" #include "loop.h"
...@@ -56,8 +56,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -56,8 +56,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* real constants: 0, 1, 1-1/REG_BR_PROB_BASE, REG_BR_PROB_BASE, /* real constants: 0, 1, 1-1/REG_BR_PROB_BASE, REG_BR_PROB_BASE,
1/REG_BR_PROB_BASE, 0.5, BB_FREQ_MAX. */ 1/REG_BR_PROB_BASE, 0.5, BB_FREQ_MAX. */
static REAL_VALUE_TYPE real_zero, real_one, real_almost_one, real_br_prob_base, static sreal real_zero, real_one, real_almost_one, real_br_prob_base,
real_inv_br_prob_base, real_one_half, real_bb_freq_max; real_inv_br_prob_base, real_one_half, real_bb_freq_max;
/* Random guesstimation given names. */ /* Random guesstimation given names. */
#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 10 - 1) #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 10 - 1)
...@@ -905,7 +905,7 @@ note_prediction_to_br_prob () ...@@ -905,7 +905,7 @@ note_prediction_to_br_prob ()
typedef struct block_info_def typedef struct block_info_def
{ {
/* Estimated frequency of execution of basic_block. */ /* Estimated frequency of execution of basic_block. */
REAL_VALUE_TYPE frequency; sreal frequency;
/* To keep queue of basic blocks to process. */ /* To keep queue of basic blocks to process. */
basic_block next; basic_block next;
...@@ -923,7 +923,7 @@ typedef struct edge_info_def ...@@ -923,7 +923,7 @@ typedef struct edge_info_def
/* In case edge is an loopback edge, the probability edge will be reached /* In case edge is an loopback edge, the probability edge will be reached
in case header is. Estimated number of iterations of the loop can be in case header is. Estimated number of iterations of the loop can be
then computed as 1 / (1 - back_edge_prob). */ then computed as 1 / (1 - back_edge_prob). */
REAL_VALUE_TYPE back_edge_prob; sreal back_edge_prob;
/* True if the edge is an loopback edge in the natural loop. */ /* True if the edge is an loopback edge in the natural loop. */
int back_edge:1; int back_edge:1;
} *edge_info; } *edge_info;
...@@ -968,7 +968,7 @@ propagate_freq (loop) ...@@ -968,7 +968,7 @@ propagate_freq (loop)
last = head; last = head;
for (bb = head; bb; bb = nextbb) for (bb = head; bb; bb = nextbb)
{ {
REAL_VALUE_TYPE cyclic_probability, frequency; sreal cyclic_probability, frequency;
memcpy (&cyclic_probability, &real_zero, sizeof (real_zero)); memcpy (&cyclic_probability, &real_zero, sizeof (real_zero));
memcpy (&frequency, &real_zero, sizeof (real_zero)); memcpy (&frequency, &real_zero, sizeof (real_zero));
...@@ -988,40 +988,42 @@ propagate_freq (loop) ...@@ -988,40 +988,42 @@ propagate_freq (loop)
for (e = bb->pred; e; e = e->pred_next) for (e = bb->pred; e; e = e->pred_next)
if (EDGE_INFO (e)->back_edge) if (EDGE_INFO (e)->back_edge)
{ {
REAL_ARITHMETIC (cyclic_probability, PLUS_EXPR, sreal_add (&cyclic_probability, &cyclic_probability,
cyclic_probability, &EDGE_INFO (e)->back_edge_prob);
EDGE_INFO (e)->back_edge_prob);
} }
else if (!(e->flags & EDGE_DFS_BACK)) else if (!(e->flags & EDGE_DFS_BACK))
{ {
REAL_VALUE_TYPE tmp; sreal tmp;
/* frequency += (e->probability /* frequency += (e->probability
* BLOCK_INFO (e->src)->frequency / * BLOCK_INFO (e->src)->frequency /
REG_BR_PROB_BASE); */ REG_BR_PROB_BASE); */
REAL_VALUE_FROM_INT (tmp, e->probability, 0, sreal_init (&tmp, e->probability, 0);
TYPE_MODE (double_type_node)); sreal_mul (&tmp, &tmp, &BLOCK_INFO (e->src)->frequency);
REAL_ARITHMETIC (tmp, MULT_EXPR, tmp, sreal_mul (&tmp, &tmp, &real_inv_br_prob_base);
BLOCK_INFO (e->src)->frequency); sreal_add (&frequency, &frequency, &tmp);
REAL_ARITHMETIC (tmp, MULT_EXPR, tmp, real_inv_br_prob_base);
REAL_ARITHMETIC (frequency, PLUS_EXPR, frequency, tmp);
} }
if (REAL_VALUES_IDENTICAL (cyclic_probability, real_zero)) if (sreal_compare (&cyclic_probability, &real_zero) == 0)
memcpy (&BLOCK_INFO (bb)->frequency, &frequency, sizeof (frequency)); {
memcpy (&BLOCK_INFO (bb)->frequency, &frequency,
sizeof (frequency));
}
else else
{ {
if (REAL_VALUES_LESS (real_almost_one, cyclic_probability)) if (sreal_compare (&cyclic_probability, &real_almost_one) > 0)
memcpy (&cyclic_probability, &real_almost_one, sizeof (real_zero)); {
memcpy (&cyclic_probability, &real_almost_one,
sizeof (real_almost_one));
}
/* BLOCK_INFO (bb)->frequency = frequency / (1 - cyclic_probability) /* BLOCK_INFO (bb)->frequency = frequency
*/ / (1 - cyclic_probability) */
REAL_ARITHMETIC (cyclic_probability, MINUS_EXPR, real_one, sreal_sub (&cyclic_probability, &real_one, &cyclic_probability);
cyclic_probability); sreal_div (&BLOCK_INFO (bb)->frequency,
REAL_ARITHMETIC (BLOCK_INFO (bb)->frequency, &frequency, &cyclic_probability);
RDIV_EXPR, frequency, cyclic_probability);
} }
} }
...@@ -1031,18 +1033,16 @@ propagate_freq (loop) ...@@ -1031,18 +1033,16 @@ propagate_freq (loop)
for (e = bb->succ; e; e = e->succ_next) for (e = bb->succ; e; e = e->succ_next)
if (e->dest == head) if (e->dest == head)
{ {
REAL_VALUE_TYPE tmp; sreal tmp;
/* EDGE_INFO (e)->back_edge_prob /* EDGE_INFO (e)->back_edge_prob
= ((e->probability * BLOCK_INFO (bb)->frequency) = ((e->probability * BLOCK_INFO (bb)->frequency)
/ REG_BR_PROB_BASE); */ / REG_BR_PROB_BASE); */
REAL_VALUE_FROM_INT (tmp, e->probability, 0,
TYPE_MODE (double_type_node));
REAL_ARITHMETIC (tmp, MULT_EXPR, tmp,
BLOCK_INFO (bb)->frequency);
REAL_ARITHMETIC (EDGE_INFO (e)->back_edge_prob,
MULT_EXPR, tmp, real_inv_br_prob_base);
sreal_init (&tmp, e->probability, 0);
sreal_mul (&tmp, &tmp, &BLOCK_INFO (bb)->frequency);
sreal_mul (&EDGE_INFO (e)->back_edge_prob,
&tmp, &real_inv_br_prob_base);
} }
/* Propagate to successor blocks. */ /* Propagate to successor blocks. */
...@@ -1160,21 +1160,19 @@ estimate_bb_frequencies (loops) ...@@ -1160,21 +1160,19 @@ estimate_bb_frequencies (loops)
struct loops *loops; struct loops *loops;
{ {
basic_block bb; basic_block bb;
REAL_VALUE_TYPE freq_max; sreal freq_max;
enum machine_mode double_mode = TYPE_MODE (double_type_node);
if (flag_branch_probabilities) if (flag_branch_probabilities)
counts_to_freqs (); counts_to_freqs ();
else else
{ {
REAL_VALUE_FROM_INT (real_zero, 0, 0, double_mode); sreal_init (&real_zero, 0, 0);
REAL_VALUE_FROM_INT (real_one, 1, 0, double_mode); sreal_init (&real_one, 1, 0);
REAL_VALUE_FROM_INT (real_br_prob_base, REG_BR_PROB_BASE, 0, double_mode); sreal_init (&real_br_prob_base, REG_BR_PROB_BASE, 0);
REAL_VALUE_FROM_INT (real_bb_freq_max, BB_FREQ_MAX, 0, double_mode); sreal_init (&real_bb_freq_max, BB_FREQ_MAX, 0);
REAL_VALUE_FROM_INT (real_one_half, 2, 0, double_mode); sreal_init (&real_one_half, 1, -1);
REAL_ARITHMETIC (real_one_half, RDIV_EXPR, real_one, real_one_half); sreal_div (&real_inv_br_prob_base, &real_one, &real_br_prob_base);
REAL_ARITHMETIC (real_inv_br_prob_base, RDIV_EXPR, real_one, real_br_prob_base); sreal_sub (&real_almost_one, &real_one, &real_inv_br_prob_base);
REAL_ARITHMETIC (real_almost_one, MINUS_EXPR, real_one, real_inv_br_prob_base);
mark_dfs_back_edges (); mark_dfs_back_edges ();
/* Fill in the probability values in flowgraph based on the REG_BR_PROB /* Fill in the probability values in flowgraph based on the REG_BR_PROB
...@@ -1215,11 +1213,10 @@ estimate_bb_frequencies (loops) ...@@ -1215,11 +1213,10 @@ estimate_bb_frequencies (loops)
BLOCK_INFO (bb)->tovisit = 0; BLOCK_INFO (bb)->tovisit = 0;
for (e = bb->succ; e; e = e->succ_next) for (e = bb->succ; e; e = e->succ_next)
{ {
REAL_VALUE_FROM_INT (EDGE_INFO (e)->back_edge_prob, sreal_init (&EDGE_INFO (e)->back_edge_prob, e->probability, 0);
e->probability, 0, double_mode); sreal_mul (&EDGE_INFO (e)->back_edge_prob,
REAL_ARITHMETIC (EDGE_INFO (e)->back_edge_prob, &EDGE_INFO (e)->back_edge_prob,
MULT_EXPR, EDGE_INFO (e)->back_edge_prob, &real_inv_br_prob_base);
real_inv_br_prob_base);
} }
} }
...@@ -1229,21 +1226,17 @@ estimate_bb_frequencies (loops) ...@@ -1229,21 +1226,17 @@ estimate_bb_frequencies (loops)
memcpy (&freq_max, &real_zero, sizeof (real_zero)); memcpy (&freq_max, &real_zero, sizeof (real_zero));
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
if (REAL_VALUES_LESS if (sreal_compare (&freq_max, &BLOCK_INFO (bb)->frequency) < 0)
(freq_max, BLOCK_INFO (bb)->frequency)) memcpy (&freq_max, &BLOCK_INFO (bb)->frequency, sizeof (freq_max));
memcpy (&freq_max, &BLOCK_INFO (bb)->frequency,
sizeof (freq_max));
REAL_ARITHMETIC (freq_max, RDIV_EXPR, real_bb_freq_max, freq_max);
sreal_div (&freq_max, &real_bb_freq_max, &freq_max);
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{ {
REAL_VALUE_TYPE tmp; sreal tmp;
REAL_ARITHMETIC (tmp, MULT_EXPR, BLOCK_INFO (bb)->frequency, sreal_mul (&tmp, &BLOCK_INFO (bb)->frequency, &freq_max);
freq_max); sreal_add (&tmp, &tmp, &real_one_half);
REAL_ARITHMETIC (tmp, PLUS_EXPR, tmp, real_one_half); bb->frequency = sreal_to_int (&tmp);
bb->frequency = REAL_VALUE_UNSIGNED_FIX (tmp);
} }
free_aux_for_blocks (); free_aux_for_blocks ();
......
This diff is collapsed. Click to expand it.
/* Definitions for simple data type for positive real numbers.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifndef GCC_SREAL_H
#define GCC_SREAL_H
/* SREAL_PART_BITS has to be an even number. */
#if (HOST_BITS_PER_WIDE_INT / 2) % 2 == 1
#define SREAL_PART_BITS (HOST_BITS_PER_WIDE_INT / 2 - 1)
#else
#define SREAL_PART_BITS (HOST_BITS_PER_WIDE_INT / 2)
#endif
#define uhwi unsigned HOST_WIDE_INT
#define MAX_HOST_WIDE_INT (((uhwi) 1 << (HOST_BITS_PER_WIDE_INT - 1)) - 1)
#define SREAL_MIN_SIG ((uhwi) 1 << (SREAL_PART_BITS - 1))
#define SREAL_MAX_SIG (((uhwi) 1 << SREAL_PART_BITS) - 1)
#define SREAL_MAX_EXP (INT_MAX / 4)
#if SREAL_PART_BITS < 32
#define SREAL_BITS (SREAL_PART_BITS * 2)
#else
#define SREAL_BITS SREAL_PART_BITS
#endif
/* Structure for holding a simple real number. */
typedef struct sreal
{
#if SREAL_PART_BITS < 32
unsigned HOST_WIDE_INT sig_lo; /* Significant (lower part). */
unsigned HOST_WIDE_INT sig_hi; /* Significant (higher part). */
#else
unsigned HOST_WIDE_INT sig; /* Significant. */
#endif
signed int exp; /* Exponent. */
} sreal;
extern void dump_sreal PARAMS ((FILE *, sreal *));
extern sreal *sreal_init PARAMS ((sreal *,
unsigned HOST_WIDE_INT,
signed int));
extern HOST_WIDE_INT sreal_to_int PARAMS ((sreal *));
extern int sreal_compare PARAMS ((sreal *, sreal *));
extern sreal *sreal_add PARAMS ((sreal *, sreal *, sreal *));
extern sreal *sreal_sub PARAMS ((sreal *, sreal *, sreal *));
extern sreal *sreal_mul PARAMS ((sreal *, sreal *, sreal *));
extern sreal *sreal_div PARAMS ((sreal *, sreal *, sreal *));
#endif
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