aboutsummaryrefslogtreecommitdiff
path: root/gcc/loop-unroll.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2012-10-20 17:51:16 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2012-10-20 15:51:16 +0000
commite598c332d81d419ecdfce59051bb4657c685e53f (patch)
tree595b4113b43061b69a63c45eb00bbb235517a85d /gcc/loop-unroll.c
parentbcd8d322db3a07471bd32ceeefbd0c5145a934ca (diff)
downloadgcc-e598c332d81d419ecdfce59051bb4657c685e53f.zip
gcc-e598c332d81d419ecdfce59051bb4657c685e53f.tar.gz
gcc-e598c332d81d419ecdfce59051bb4657c685e53f.tar.bz2
unroll-1.c: New testcase.
* gcc.dg/tree-prof/unroll-1.c: New testcase. * loop-unroll.c (decide_unroll_constant_iterations): Don't perform unrolling for loops with low iterations bounds or estimates. From-SVN: r192638
Diffstat (limited to 'gcc/loop-unroll.c')
-rw-r--r--gcc/loop-unroll.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 0dd8b0a..2398e6d 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -519,6 +519,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
{
unsigned nunroll, nunroll_by_av, best_copies, best_unroll = 0, n_copies, i;
struct niter_desc *desc;
+ double_int iterations;
if (!(flags & UAP_UNROLL))
{
@@ -561,8 +562,14 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
return;
}
- /* Check whether the loop rolls enough to consider. */
- if (desc->niter < 2 * nunroll)
+ /* Check whether the loop rolls enough to consider.
+ Consult also loop bounds and profile; in the case the loop has more
+ than one exit it may well loop less than determined maximal number
+ of iterations. */
+ if (desc->niter < 2 * nunroll
+ || ((estimated_loop_iterations (loop, &iterations)
+ || max_loop_iterations (loop, &iterations))
+ && iterations.ult (double_int::from_shwi (2 * nunroll))))
{
if (dump_file)
fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");