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
This commit is contained in:
Jan Hubicka 2001-06-12 10:22:22 +00:00
parent 7bdcf888aa
commit aa18f20e74
3 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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");

View File

@ -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)