This makes us also use max-iteration knowledge when considering costs for prefetching and parallelization instead of only relying on iteration estimates which are sometimes not available.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-04-11 Richard Guenther <rguent...@suse.de> * tree-parloops.c (parallelize_loops): Also consult the upper bound for the number of iterations. * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Likewise. (loop_prefetch_arrays): Likewise. Index: trunk/gcc/tree-parloops.c =================================================================== *** trunk.orig/gcc/tree-parloops.c 2012-04-11 16:31:08.000000000 +0200 --- trunk/gcc/tree-parloops.c 2012-04-11 16:39:25.271205694 +0200 *************** parallelize_loops (void) *** 2192,2203 **** header-copied loops correctly - see PR46886. */ || !do_while_loop_p (loop)) continue; estimated = estimated_stmt_executions_int (loop); /* FIXME: Bypass this check as graphite doesn't update the ! count and frequency correctly now. */ if (!flag_loop_parallelize_all ! && ((estimated !=-1 ! && estimated <= (HOST_WIDE_INT) n_threads * MIN_PER_THREAD) /* Do not bother with loops in cold areas. */ || optimize_loop_nest_for_size_p (loop))) continue; --- 2192,2206 ---- header-copied loops correctly - see PR46886. */ || !do_while_loop_p (loop)) continue; + estimated = estimated_stmt_executions_int (loop); + if (estimated == -1) + estimated = max_stmt_executions_int (loop); /* FIXME: Bypass this check as graphite doesn't update the ! count and frequency correctly now. */ if (!flag_loop_parallelize_all ! && ((estimated != -1 ! && estimated <= (HOST_WIDE_INT) n_threads * MIN_PER_THREAD) /* Do not bother with loops in cold areas. */ || optimize_loop_nest_for_size_p (loop))) continue; Index: trunk/gcc/tree-ssa-loop-prefetch.c =================================================================== *** trunk.orig/gcc/tree-ssa-loop-prefetch.c 2012-04-11 16:31:08.000000000 +0200 --- trunk/gcc/tree-ssa-loop-prefetch.c 2012-04-11 16:42:45.864193724 +0200 *************** determine_loop_nest_reuse (struct loop * *** 1549,1555 **** aloop = VEC_index (loop_p, vloops, i); vol = estimated_stmt_executions_int (aloop); ! if (vol < 0) vol = expected_loop_iterations (aloop); volume *= vol; } --- 1549,1555 ---- aloop = VEC_index (loop_p, vloops, i); vol = estimated_stmt_executions_int (aloop); ! if (vol == -1) vol = expected_loop_iterations (aloop); volume *= vol; } *************** loop_prefetch_arrays (struct loop *loop) *** 1801,1806 **** --- 1801,1808 ---- ahead = (PREFETCH_LATENCY + time - 1) / time; est_niter = estimated_stmt_executions_int (loop); + if (est_niter == -1) + est_niter = max_stmt_executions_int (loop); /* Prefetching is not likely to be profitable if the trip count to ahead ratio is too small. */