From: Jan Hubicka Date: Tue, 12 Jun 2001 10:22:22 +0000 (+0000) Subject: loop.c: Include predict.h X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa18f20e7406ee235e94d6360bf4b3e349088544;p=gcc.git loop.c: Include predict.h * 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 From-SVN: r43251 --- 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)