diff options
author | Jan Hubicka <jh@suse.cz> | 2001-08-25 23:08:28 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2001-08-25 21:08:28 +0000 |
commit | 6ab16dd9ad5daa079e0ad3312b1324a4dd51b8bb (patch) | |
tree | 148dfc2b03bed81cf63c2e3eb8ec9d70ddd5db7c /gcc/predict.c | |
parent | 033c017cb2c0234ef0518856ce8310a11626c5b3 (diff) | |
download | gcc-6ab16dd9ad5daa079e0ad3312b1324a4dd51b8bb.zip gcc-6ab16dd9ad5daa079e0ad3312b1324a4dd51b8bb.tar.gz gcc-6ab16dd9ad5daa079e0ad3312b1324a4dd51b8bb.tar.bz2 |
predict.c (expensive_function_p): New.
* predict.c (expensive_function_p): New.
* rtl.h (expensive_function_p): Declare.
* i386.c (FAST_PROLOGUE_INSN_COUNT): New constant.
(use_fast_prologue_epilogue): New static variable.
(expand_prologue): Set it; emit short prologues if unset.
(expand_epilogue): Likewise.
From-SVN: r45176
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index f7e8b6d..70460ab 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -782,6 +782,51 @@ counts_to_freqs () } } +/* Return true if function is likely to be expensive, so there is no point + to optimizer performance of prologue, epilogue or do inlining at the + expense of code size growth. THRESHOLD is the limit of number + of isntructions function can execute at average to be still considered + not expensive. */ +bool +expensive_function_p (threshold) + int threshold; +{ + unsigned int sum = 0; + int i; + int limit; + + /* We can not compute accurately for large thresholds due to scaled + frequencies. */ + if (threshold > BB_FREQ_MAX) + abort (); + + /* Frequencies are out of range. This eighter means that function contains + internal loop executing more than BB_FREQ_MAX times or profile feedback + is available and function has not been executed at all. */ + if (ENTRY_BLOCK_PTR->frequency == 0) + return true; + + /* Maximally BB_FREQ_MAX^2 so overflow won't happen. */ + limit = ENTRY_BLOCK_PTR->frequency * threshold; + for (i = 0; i < n_basic_blocks; i++) + { + basic_block bb = BASIC_BLOCK (i); + rtx insn; + + for (insn = bb->head; insn != NEXT_INSN (bb->end); + insn = NEXT_INSN (insn)) + { + if (active_insn_p (insn)) + { + sum += bb->frequency; + if (sum > limit) + return true; + } + } + } + return false; +} + /* Estimate basic blocks frequency by given branch probabilities. */ static void estimate_bb_frequencies (loops) |