summaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-25 21:08:28 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-25 21:08:28 +0000
commitf4c0c1a259e6ba8b205f9599fb876d9f0780d2d8 (patch)
tree148dfc2b03bed81cf63c2e3eb8ec9d70ddd5db7c /gcc/predict.c
parentfc97b23335a7f430ca58aed4631109b68285da0e (diff)
downloadgcc-f4c0c1a259e6ba8b205f9599fb876d9f0780d2d8.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45176 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index f7e8b6d77a4..70460ab3b46 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)