diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-12 10:22:22 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-12 10:22:22 +0000 |
commit | 482cd3c164c13038d7c0230946014754ae161fec (patch) | |
tree | 487d80a5d58a9011b3ff04980963adc35c2b444a | |
parent | 1bea8da88c4eb517e110b8f11b758a2ea5ea9959 (diff) | |
download | gcc-482cd3c164c13038d7c0230946014754ae161fec.tar.gz |
* loop.c: Include predict.h
(strength_reduce): Drop branch prediction note in case
number of iterations is known.
* predict.def (PRED_LOOP_ITERATIONS): new.
* Makefile.in (loop.o): Add dependancy on predict.h
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@43251 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/loop.c | 13 | ||||
-rw-r--r-- | gcc/predict.def | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index a9af1e1cdf9..6ed6e3f9283 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1438,7 +1438,7 @@ profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \ insn-config.h output.h $(REGS_H) $(EXPR_H) function.h \ gcov-io.h toplev.h $(GGC_H) hard-reg-set.h $(BASIC_BLOCK_H) loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h $(LOOP_H) insn-config.h \ - $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h \ + $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h $(PREDICT_H) \ $(BASIC_BLOCK_H) function.h toplev.h varray.h except.h cselib.h $(TM_P_H) doloop.o : doloop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h $(LOOP_H) \ $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) $(TM_P_H) toplev.h diff --git a/gcc/loop.c b/gcc/loop.c index 34bc862b5ac..fac9a840bc8 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -52,6 +52,7 @@ Boston, MA 02111-1307, USA. */ #include "cselib.h" #include "except.h" #include "toplev.h" +#include "predict.h" #define LOOP_REG_LIFETIME(LOOP, REGNO) \ ((REGNO_LAST_LUID (REGNO) - REGNO_FIRST_LUID (REGNO))) @@ -4498,6 +4499,18 @@ strength_reduce (loop, flags) doloop_optimize (loop); #endif /* HAVE_doloop_end */ + /* In case number of iterations is known, drop branch prediction note + in the branch. Do that only in second loop pass, as loop unrolling + may change the number of iterations performed. */ + if ((flags & LOOP_BCT) + && loop_info->n_iterations / loop_info->unroll_number > 1) + { + int n = loop_info->n_iterations / loop_info->unroll_number - 1; + predict_insn (PREV_INSN (loop->end), + PRED_LOOP_ITERATIONS, + REG_BR_PROB_BASE - REG_BR_PROB_BASE / n); + } + if (loop_dump_stream) fprintf (loop_dump_stream, "\n"); diff --git a/gcc/predict.def b/gcc/predict.def index f910f3ba72f..01d87a4c3f0 100644 --- a/gcc/predict.def +++ b/gcc/predict.def @@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA. */ DEF_PREDICTOR (PRED_FIRST_MATCH, "first match", PROB_ALWAYS) DEF_PREDICTOR (PRED_UNCONDITIONAL, "unconditional jump", PROB_ALWAYS) +DEF_PREDICTOR (PRED_LOOP_ITERATIONS, "loop iterations", PROB_ALWAYS) DEF_PREDICTOR (PRED_BUILTIN_EXPECT, "__builtin_expect", PROB_VERY_LIKELY) DEF_PREDICTOR (PRED_NORETURN, "noreturn call", PROB_ALWAYS) DEF_PREDICTOR (PRED_LOOP_BRANCH, "loop branch", PROB_VERY_LIKELY) |