diff options
author | zlomek <zlomek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-15 12:07:46 +0000 |
---|---|---|
committer | zlomek <zlomek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-15 12:07:46 +0000 |
commit | 2e3c56e8025386f0ecaa6e300038560ce4fa78c1 (patch) | |
tree | f85fdb4afd85f5211f727167742b5a1bbcb1197e /gcc/predict.c | |
parent | ef9a8a4133f4f6d1cc6374ad42d1ef4db4a2d227 (diff) | |
download | gcc-2e3c56e8025386f0ecaa6e300038560ce4fa78c1.tar.gz |
Segher Boessenkool <segher@koffie.nl>
* predict.c (real_inv_br_prob_base): New variable.
(propagate_freq): Use multiply by reciprocal instead of
division. Don't divide by 1.0 at all.
(estimate_bb_frequencies): Similar.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61326 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 3f3e2fc37bc..4ca71d3b0d2 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -53,10 +53,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "target.h" #include "loop.h" -/* real constants: 0, 1, 1-1/REG_BR_PROB_BASE, REG_BR_PROB_BASE, 0.5, - REAL_BB_FREQ_MAX. */ +/* real constants: 0, 1, 1-1/REG_BR_PROB_BASE, REG_BR_PROB_BASE, + 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, - real_one_half, real_bb_freq_max; + real_inv_br_prob_base, real_one_half, real_bb_freq_max; /* Random guesstimation given names. */ #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 10 - 1) @@ -988,20 +988,25 @@ propagate_freq (loop) TYPE_MODE (double_type_node)); REAL_ARITHMETIC (tmp, MULT_EXPR, tmp, BLOCK_INFO (e->src)->frequency); - REAL_ARITHMETIC (tmp, RDIV_EXPR, tmp, real_br_prob_base); + REAL_ARITHMETIC (tmp, MULT_EXPR, tmp, real_inv_br_prob_base); REAL_ARITHMETIC (frequency, PLUS_EXPR, frequency, tmp); } - if (REAL_VALUES_LESS (real_almost_one, cyclic_probability)) - memcpy (&cyclic_probability, &real_almost_one, sizeof (real_zero)); + if (REAL_VALUES_IDENTICAL (cyclic_probability, real_zero)) + memcpy (&BLOCK_INFO (bb)->frequency, &frequency, sizeof (frequency)); + else + { + if (REAL_VALUES_LESS (real_almost_one, cyclic_probability)) + memcpy (&cyclic_probability, &real_almost_one, sizeof (real_zero)); - /* BLOCK_INFO (bb)->frequency = frequency / (1 - cyclic_probability) - */ + /* BLOCK_INFO (bb)->frequency = frequency / (1 - cyclic_probability) + */ - REAL_ARITHMETIC (cyclic_probability, MINUS_EXPR, real_one, + REAL_ARITHMETIC (cyclic_probability, MINUS_EXPR, real_one, cyclic_probability); - REAL_ARITHMETIC (BLOCK_INFO (bb)->frequency, - RDIV_EXPR, frequency, cyclic_probability); + REAL_ARITHMETIC (BLOCK_INFO (bb)->frequency, + RDIV_EXPR, frequency, cyclic_probability); + } } BLOCK_INFO (bb)->tovisit = 0; @@ -1020,7 +1025,7 @@ propagate_freq (loop) REAL_ARITHMETIC (tmp, MULT_EXPR, tmp, BLOCK_INFO (bb)->frequency); REAL_ARITHMETIC (EDGE_INFO (e)->back_edge_prob, - RDIV_EXPR, tmp, real_br_prob_base); + MULT_EXPR, tmp, real_inv_br_prob_base); } @@ -1151,11 +1156,9 @@ estimate_bb_frequencies (loops) REAL_VALUE_FROM_INT (real_br_prob_base, REG_BR_PROB_BASE, 0, double_mode); REAL_VALUE_FROM_INT (real_bb_freq_max, BB_FREQ_MAX, 0, double_mode); REAL_VALUE_FROM_INT (real_one_half, 2, 0, double_mode); - REAL_ARITHMETIC (real_one_half, RDIV_EXPR, real_one, real_one_half); - - REAL_ARITHMETIC (real_almost_one, RDIV_EXPR, real_one, real_br_prob_base); - REAL_ARITHMETIC (real_almost_one, MINUS_EXPR, real_one, real_almost_one); + REAL_ARITHMETIC (real_inv_br_prob_base, RDIV_EXPR, real_one, real_br_prob_base); + REAL_ARITHMETIC (real_almost_one, MINUS_EXPR, real_one, real_inv_br_prob_base); mark_dfs_back_edges (); /* Fill in the probability values in flowgraph based on the REG_BR_PROB @@ -1199,8 +1202,8 @@ estimate_bb_frequencies (loops) REAL_VALUE_FROM_INT (EDGE_INFO (e)->back_edge_prob, e->probability, 0, double_mode); REAL_ARITHMETIC (EDGE_INFO (e)->back_edge_prob, - RDIV_EXPR, EDGE_INFO (e)->back_edge_prob, - real_br_prob_base); + MULT_EXPR, EDGE_INFO (e)->back_edge_prob, + real_inv_br_prob_base); } } @@ -1215,13 +1218,14 @@ estimate_bb_frequencies (loops) memcpy (&freq_max, &BLOCK_INFO (bb)->frequency, sizeof (freq_max)); + REAL_ARITHMETIC (freq_max, RDIV_EXPR, real_bb_freq_max, freq_max); + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) { REAL_VALUE_TYPE tmp; REAL_ARITHMETIC (tmp, MULT_EXPR, BLOCK_INFO (bb)->frequency, - real_bb_freq_max); - REAL_ARITHMETIC (tmp, RDIV_EXPR, tmp, freq_max); + freq_max); REAL_ARITHMETIC (tmp, PLUS_EXPR, tmp, real_one_half); bb->frequency = REAL_VALUE_UNSIGNED_FIX (tmp); } |