/* Perform doloop optimizations
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
Based on code by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
This file is part of GCC.
do_compare_rtx_and_jump (op0, op1, code, 0, mode, NULL_RTX, NULL_RTX, label);
jump = get_last_insn ();
- if (!JUMP_P (jump))
+ if (!jump || !JUMP_P (jump))
{
/* The condition is always false and the jump was optimized out. */
end_sequence ();
seq = get_insns ();
end_sequence ();
- bb = loop_split_edge_with (*e, seq);
+
+ /* There always is at least the jump insn in the sequence. */
+ gcc_assert (seq != NULL_RTX);
+
+ bb = split_edge_and_insert (*e, seq);
*e = single_succ_edge (bb);
if (any_uncondjump_p (jump))
rtx ass = copy_rtx (desc->noloop_assumptions);
basic_block preheader = loop_preheader_edge (loop)->src;
basic_block set_zero
- = loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
+ = split_edge (loop_preheader_edge (loop));
basic_block new_preheader
- = loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
+ = split_edge (loop_preheader_edge (loop));
edge te;
/* Expand the condition testing the assumptions and if it does not pass,
{
/* All the conditions were simplified to false, remove the
unreachable set_zero block. */
- remove_bb_from_loops (set_zero);
delete_basic_block (set_zero);
}
else
rtx start_label;
rtx condition;
unsigned level, est_niter;
+ int max_cost;
struct niter_desc *desc;
unsigned word_mode_size;
unsigned HOST_WIDE_INT word_mode_max;
return false;
}
+ max_cost
+ = COSTS_N_INSNS (PARAM_VALUE (PARAM_MAX_ITERATIONS_COMPUTATION_COST));
+ if (rtx_cost (desc->niter_expr, SET) > max_cost)
+ {
+ if (dump_file)
+ fprintf (dump_file,
+ "Doloop: number of iterations too costly to compute.\n");
+ return false;
+ }
+
count = copy_rtx (desc->niter_expr);
iterations = desc->const_iter ? desc->niter_expr : const0_rtx;
iterations_max = GEN_INT (desc->niter_max);
return true;
}
-/* This is the main entry point. Process all LOOPS using doloop_optimize. */
+/* This is the main entry point. Process all loops using doloop_optimize. */
void
-doloop_optimize_loops (struct loops *loops)
+doloop_optimize_loops (void)
{
- unsigned i;
+ loop_iterator li;
struct loop *loop;
- for (i = 1; i < loops->num; i++)
+ FOR_EACH_LOOP (li, loop, 0)
{
- loop = loops->parray[i];
- if (!loop)
- continue;
-
doloop_optimize (loop);
}
#ifdef ENABLE_CHECKING
verify_dominators (CDI_DOMINATORS);
- verify_loop_structure (loops);
+ verify_loop_structure ();
#endif
}
#endif /* HAVE_doloop_end */