mirror of git://gcc.gnu.org/git/gcc.git
loop-unroll.c (unroll_loop_runtime_iterations): Condition initial loop peel to loops with exit test at the beginning.
* loop-unroll.c (unroll_loop_runtime_iterations): Condition initial loop peel to loops with exit test at the beginning. From-SVN: r241173
This commit is contained in:
parent
db2fb304fe
commit
de0a3fa38e
|
|
@ -1,3 +1,8 @@
|
||||||
|
2016-10-14 Pat Haugen <pthaugen@us.ibm.com>
|
||||||
|
|
||||||
|
* loop-unroll.c (unroll_loop_runtime_iterations): Condition initial
|
||||||
|
loop peel to loops with exit test at the beginning.
|
||||||
|
|
||||||
2016-10-14 Pat Haugen <pthaugen@us.ibm.com>
|
2016-10-14 Pat Haugen <pthaugen@us.ibm.com>
|
||||||
|
|
||||||
PR rtl-optimization/68212
|
PR rtl-optimization/68212
|
||||||
|
|
|
||||||
|
|
@ -858,7 +858,7 @@ unroll_loop_runtime_iterations (struct loop *loop)
|
||||||
rtx old_niter, niter, tmp;
|
rtx old_niter, niter, tmp;
|
||||||
rtx_insn *init_code, *branch_code;
|
rtx_insn *init_code, *branch_code;
|
||||||
unsigned i, j, p;
|
unsigned i, j, p;
|
||||||
basic_block preheader, *body, swtch, ezc_swtch;
|
basic_block preheader, *body, swtch, ezc_swtch = NULL;
|
||||||
int may_exit_copy, iter_freq, new_freq;
|
int may_exit_copy, iter_freq, new_freq;
|
||||||
gcov_type iter_count, new_count;
|
gcov_type iter_count, new_count;
|
||||||
unsigned n_peel;
|
unsigned n_peel;
|
||||||
|
|
@ -918,6 +918,16 @@ unroll_loop_runtime_iterations (struct loop *loop)
|
||||||
if (tmp != niter)
|
if (tmp != niter)
|
||||||
emit_move_insn (niter, tmp);
|
emit_move_insn (niter, tmp);
|
||||||
|
|
||||||
|
/* For loops that exit at end, add one to niter to account for first pass
|
||||||
|
through loop body before reaching exit test. */
|
||||||
|
if (exit_at_end)
|
||||||
|
{
|
||||||
|
niter = expand_simple_binop (desc->mode, PLUS,
|
||||||
|
niter, const1_rtx,
|
||||||
|
NULL_RTX, 0, OPTAB_LIB_WIDEN);
|
||||||
|
old_niter = niter;
|
||||||
|
}
|
||||||
|
|
||||||
/* Count modulo by ANDing it with max_unroll; we use the fact that
|
/* Count modulo by ANDing it with max_unroll; we use the fact that
|
||||||
the number of unrollings is a power of two, and thus this is correct
|
the number of unrollings is a power of two, and thus this is correct
|
||||||
even if there is overflow in the computation. */
|
even if there is overflow in the computation. */
|
||||||
|
|
@ -936,13 +946,13 @@ unroll_loop_runtime_iterations (struct loop *loop)
|
||||||
|
|
||||||
auto_sbitmap wont_exit (max_unroll + 2);
|
auto_sbitmap wont_exit (max_unroll + 2);
|
||||||
|
|
||||||
/* Peel the first copy of loop body (almost always we must leave exit test
|
if (extra_zero_check)
|
||||||
here; the only exception is when we have extra zero check and the number
|
{
|
||||||
of iterations is reliable. Also record the place of (possible) extra
|
/* Peel the first copy of loop body. Leave the exit test if the number
|
||||||
zero check. */
|
of iterations is not reliable. Also record the place of the extra zero
|
||||||
|
check. */
|
||||||
bitmap_clear (wont_exit);
|
bitmap_clear (wont_exit);
|
||||||
if (extra_zero_check
|
if (!desc->noloop_assumptions)
|
||||||
&& !desc->noloop_assumptions)
|
|
||||||
bitmap_set_bit (wont_exit, 1);
|
bitmap_set_bit (wont_exit, 1);
|
||||||
ezc_swtch = loop_preheader_edge (loop)->src;
|
ezc_swtch = loop_preheader_edge (loop)->src;
|
||||||
ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
|
ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
|
||||||
|
|
@ -950,6 +960,7 @@ unroll_loop_runtime_iterations (struct loop *loop)
|
||||||
&remove_edges,
|
&remove_edges,
|
||||||
DLTHE_FLAG_UPDATE_FREQ);
|
DLTHE_FLAG_UPDATE_FREQ);
|
||||||
gcc_assert (ok);
|
gcc_assert (ok);
|
||||||
|
}
|
||||||
|
|
||||||
/* Record the place where switch will be built for preconditioning. */
|
/* Record the place where switch will be built for preconditioning. */
|
||||||
swtch = split_edge (loop_preheader_edge (loop));
|
swtch = split_edge (loop_preheader_edge (loop));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue