diff options
Diffstat (limited to 'gcc/loop-doloop.c')
-rw-r--r-- | gcc/loop-doloop.c | 89 |
1 files changed, 23 insertions, 66 deletions
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c index 0b6447adede..6554597ba86 100644 --- a/gcc/loop-doloop.c +++ b/gcc/loop-doloop.c @@ -21,25 +21,12 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" +#include "backend.h" +#include "cfghooks.h" #include "rtl.h" #include "flags.h" -#include "symtab.h" -#include "hashtab.h" -#include "hash-set.h" -#include "vec.h" -#include "machmode.h" -#include "hard-reg-set.h" -#include "input.h" -#include "function.h" -#include "statistics.h" -#include "double-int.h" -#include "real.h" -#include "fixed-value.h" -#include "alias.h" -#include "wide-int.h" -#include "inchash.h" #include "tree.h" +#include "alias.h" #include "insn-config.h" #include "expmed.h" #include "dojump.h" @@ -51,12 +38,8 @@ along with GCC; see the file COPYING3. If not see #include "expr.h" #include "diagnostic-core.h" #include "tm_p.h" -#include "predict.h" -#include "dominance.h" -#include "cfg.h" #include "cfgloop.h" #include "cfgrtl.h" -#include "basic-block.h" #include "params.h" #include "target.h" #include "dumpfile.h" @@ -91,8 +74,6 @@ along with GCC; see the file COPYING3. If not see register cannot be used for anything else but doloop -- ??? detect these cases). */ -#ifdef HAVE_doloop_end - /* Return the loop termination condition for PATTERN or zero if it is not a decrement and branch jump insn. */ @@ -141,7 +122,7 @@ doloop_condition_get (rtx doloop_pat) if (GET_CODE (pattern) != PARALLEL) { rtx cond; - rtx prev_insn = prev_nondebug_insn (doloop_pat); + rtx_insn *prev_insn = prev_nondebug_insn (doloop_pat); rtx cmp_arg1, cmp_arg2; rtx cmp_orig; @@ -365,7 +346,7 @@ static bool add_test (rtx cond, edge *e, basic_block dest) { rtx_insn *seq, *jump; - rtx label; + rtx_code_label *label; machine_mode mode; rtx op0 = XEXP (cond, 0), op1 = XEXP (cond, 1); enum rtx_code code = GET_CODE (cond); @@ -379,8 +360,7 @@ add_test (rtx cond, edge *e, basic_block dest) op0 = force_operand (op0, NULL_RTX); op1 = force_operand (op1, NULL_RTX); label = block_label (dest); - do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, - NULL_RTX, label, -1); + do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, NULL, label, -1); jump = get_last_insn (); if (!jump || !JUMP_P (jump)) @@ -426,13 +406,13 @@ add_test (rtx cond, edge *e, basic_block dest) static void doloop_modify (struct loop *loop, struct niter_desc *desc, - rtx doloop_seq, rtx condition, rtx count) + rtx_insn *doloop_seq, rtx condition, rtx count) { rtx counter_reg; rtx tmp, noloop = NULL_RTX; rtx_insn *sequence; rtx_insn *jump_insn; - rtx jump_label; + rtx_code_label *jump_label; int nonneg = 0; bool increment_count; basic_block loop_end = desc->out_edge->src; @@ -446,7 +426,7 @@ doloop_modify (struct loop *loop, struct niter_desc *desc, { fprintf (dump_file, "Doloop: Inserting doloop pattern ("); if (desc->const_iter) - fprintf (dump_file, "%"PRId64, desc->niter); + fprintf (dump_file, "%" PRId64, desc->niter); else fputs ("runtime", dump_file); fputs (" iterations).\n", dump_file); @@ -574,21 +554,9 @@ doloop_modify (struct loop *loop, struct niter_desc *desc, /* Some targets (eg, C4x) need to initialize special looping registers. */ -#ifdef HAVE_doloop_begin - { - rtx init; - - init = gen_doloop_begin (counter_reg, doloop_seq); - if (init) - { - start_sequence (); - emit_insn (init); - sequence = get_insns (); - end_sequence (); - emit_insn_after (sequence, BB_END (loop_preheader_edge (loop)->src)); - } - } -#endif + if (targetm.have_doloop_begin ()) + if (rtx_insn *seq = targetm.gen_doloop_begin (counter_reg, doloop_seq)) + emit_insn_after (seq, BB_END (loop_preheader_edge (loop)->src)); /* Insert the new low-overhead looping insn. */ emit_jump_insn_after (doloop_seq, BB_END (loop_end)); @@ -624,10 +592,10 @@ static bool doloop_optimize (struct loop *loop) { machine_mode mode; - rtx doloop_seq, doloop_pat, doloop_reg; + rtx doloop_reg; rtx count; widest_int iterations, iterations_max; - rtx start_label; + rtx_code_label *start_label; rtx condition; unsigned level, est_niter; int max_cost; @@ -674,7 +642,7 @@ doloop_optimize (struct loop *loop) max_cost = COSTS_N_INSNS (PARAM_VALUE (PARAM_MAX_ITERATIONS_COMPUTATION_COST)); - if (set_src_cost (desc->niter_expr, optimize_loop_for_speed_p (loop)) + if (set_src_cost (desc->niter_expr, mode, optimize_loop_for_speed_p (loop)) > max_cost) { if (dump_file) @@ -707,7 +675,7 @@ doloop_optimize (struct loop *loop) count = copy_rtx (desc->niter_expr); start_label = block_label (desc->in_edge->dest); doloop_reg = gen_reg_rtx (mode); - doloop_seq = gen_doloop_end (doloop_reg, start_label); + rtx_insn *doloop_seq = targetm.gen_doloop_end (doloop_reg, start_label); word_mode_size = GET_MODE_PRECISION (word_mode); word_mode_max @@ -725,7 +693,7 @@ doloop_optimize (struct loop *loop) else count = lowpart_subreg (word_mode, count, mode); PUT_MODE (doloop_reg, word_mode); - doloop_seq = gen_doloop_end (doloop_reg, start_label); + doloop_seq = targetm.gen_doloop_end (doloop_reg, start_label); } if (! doloop_seq) { @@ -736,21 +704,12 @@ doloop_optimize (struct loop *loop) } /* If multiple instructions were created, the last must be the - jump instruction. Also, a raw define_insn may yield a plain - pattern. */ - doloop_pat = doloop_seq; - if (INSN_P (doloop_pat)) - { - rtx_insn *doloop_insn = as_a <rtx_insn *> (doloop_pat); - while (NEXT_INSN (doloop_insn) != NULL_RTX) - doloop_insn = NEXT_INSN (doloop_insn); - if (!JUMP_P (doloop_insn)) - doloop_insn = NULL; - doloop_pat = doloop_insn; - } - - if (! doloop_pat - || ! (condition = doloop_condition_get (doloop_pat))) + jump instruction. */ + rtx_insn *doloop_insn = doloop_seq; + while (NEXT_INSN (doloop_insn) != NULL_RTX) + doloop_insn = NEXT_INSN (doloop_insn); + if (!JUMP_P (doloop_insn) + || !(condition = doloop_condition_get (doloop_insn))) { if (dump_file) fprintf (dump_file, "Doloop: Unrecognizable doloop pattern!\n"); @@ -779,5 +738,3 @@ doloop_optimize_loops (void) verify_loop_structure (); #endif } -#endif /* HAVE_doloop_end */ - |