Hi,
this patch re-applies the idx_infer_loop_bounds. With fix to the
tree-vect-loop.c
change there should be no performance regressions. Prefetch-5.c testcase still
changes
and I will send patch adding likely upper bounds shortly to handle this one.
Bootstrapped/regtested x86_64-linux, comitted.
Honza
* gcc.dg/tree-ssa/prefetch-5.c: xfail.
* tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can not produce
realistic upper bounds here.
Index: testsuite/gcc.dg/tree-ssa/prefetch-5.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/prefetch-5.c (revision 236478)
+++ testsuite/gcc.dg/tree-ssa/prefetch-5.c (working copy)
@@ -54,5 +54,7 @@ int loop5 (int n, struct tail5 *x)
return s;
}
-/* { dg-final { scan-tree-dump-times "Issued prefetch" 2 "aprefetch" } } */
-/* { dg-final { scan-tree-dump-times "Not prefetching" 1 "aprefetch" } } */
+/* Until we are able to track likely upper bounds, we can't really work out
that
+ small trailing arrays should not be prefetched. */
+/* { dg-final { scan-tree-dump-times "Issued prefetch" 2 "aprefetch" { xfail
*-*-* } } } */
+/* { dg-final { scan-tree-dump-times "Not prefetching" 1 "aprefetch" { xfail
*-*-* } } } */
Index: tree-ssa-loop-niter.c
===================================================================
--- tree-ssa-loop-niter.c (revision 236478)
+++ tree-ssa-loop-niter.c (working copy)
@@ -3115,7 +3115,6 @@ idx_infer_loop_bounds (tree base, tree *
tree low, high, type, next;
bool sign, upper = true, at_end = false;
struct loop *loop = data->loop;
- bool reliable = true;
if (TREE_CODE (base) != ARRAY_REF)
return true;
@@ -3187,14 +3186,14 @@ idx_infer_loop_bounds (tree base, tree *
&& tree_int_cst_compare (next, high) <= 0)
return true;
- /* If access is not executed on every iteration, we must ensure that overlow
may
- not make the access valid later. */
+ /* If access is not executed on every iteration, we must ensure that overlow
+ may not make the access valid later. */
if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (data->stmt))
&& scev_probably_wraps_p (initial_condition_in_loop_num (ev, loop->num),
step, data->stmt, loop, true))
- reliable = false;
+ upper = false;
- record_nonwrapping_iv (loop, init, step, data->stmt, low, high, reliable,
upper);
+ record_nonwrapping_iv (loop, init, step, data->stmt, low, high, false,
upper);
return true;
}