Commit f2a1b469 by Jan Hubicka Committed by Jan Hubicka

re PR tree-optimization/55079 (false positive -Warray-bounds (also seen at -O3 bootstrap))


	PR middle-end/55079
	* tree-ssa-loop-niter.c (number_of_iterations_exit): Update
	MAX field if NITER was folded to contant.
	(record_estimate): Sanity check.
	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): New
	function.
	(remove_redundant_iv_test): New function.
	(loops_to_unloop, loops_to_unloop_nunroll): New static vars.
	(unloop_loops): Break out from ...
	(try_unroll_loop_completely): ... here; Pass in MAXITER; use
	remove_exits_and_undefined_stmts; do not unloop.
	(canonicalize_loop_induction_variables): Compute MAXITER;
	use remove_redundant_iv_test; remove loop_close_ssa_invalidated
	and irred_invalidated arguments.
	(canonicalize_induction_variables): Compute fresh bound estimates;
	unloop; walk from innermost.
	(tree_unroll_loops_completely): Likewise.

	* gcc.dg/tree-ssa/cunroll-10.c: New testcase.
	* gcc.dg/tree-ssa/cunroll-9.c: New testcase.

From-SVN: r193098
parent 7ee840b6
2012-11-02 Jan Hubicka <jh@suse.cz>
PR middle-end/55079
* tree-ssa-loop-niter.c (number_of_iterations_exit): Update
MAX field if NITER was folded to contant.
(record_estimate): Sanity check.
* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): New
function.
(remove_redundant_iv_test): New function.
(loops_to_unloop, loops_to_unloop_nunroll): New static vars.
(unloop_loops): Break out from ...
(try_unroll_loop_completely): ... here; Pass in MAXITER; use
remove_exits_and_undefined_stmts; do not unloop.
(canonicalize_loop_induction_variables): Compute MAXITER;
use remove_redundant_iv_test; remove loop_close_ssa_invalidated
and irred_invalidated arguments.
(canonicalize_induction_variables): Compute fresh bound estimates;
unloop; walk from innermost.
(tree_unroll_loops_completely): Likewise.
2012-11-02 Vladimir Makarov <vmakarov@redhat.com>
PR middle-end/55130
2012-11-02 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/cunroll-10.c: New testcase.
* gcc.dg/tree-ssa/cunroll-9.c: New testcase.
2012-11-02 Vladimir Makarov <vmakarov@redhat.com>
PR middle-end/55130
......
/* { dg-do compile } */
/* { dg-options "-O3 -Warray-bounds -fdump-tree-cunroll-details" } */
int a[3];
int b[4];
main()
{
int i;
for (i=0;i<4;i++)
if (b[i]==2)
a[i]++;
}
/* { dg-final { scan-tree-dump-times "Forced statement unreachable" 2 "cunroll" } } */
/* { dg-final { cleanup-tree-dump "cunroll" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-cunrolli" } */
void abort (void);
int a[10];
int b[11];
t (int n)
{
int i;
int sum = 0;
for (i = 0; i < n; i++)
{
if (i > 1000)
abort ();
if (q ())
sum += a[i];
else
sum += b[i];
}
return sum;
}
/* { dg-final { scan-tree-dump-times 1 "Removed pointless exit:" "cunroli" } } */
/* { dg-final { cleanup-tree-dump "cunroli" } } */
......@@ -1880,6 +1880,10 @@ number_of_iterations_exit (struct loop *loop, edge exit,
fold_undefer_and_ignore_overflow_warnings ();
/* If NITER has simplified into a constant, update MAX. */
if (TREE_CODE (niter->niter) == INTEGER_CST)
niter->max = tree_to_double_int (niter->niter);
if (integer_onep (niter->assumptions))
return true;
......@@ -2556,6 +2560,8 @@ record_estimate (struct loop *loop, tree bound, double_int i_bound,
real number of iterations. */
if (TREE_CODE (bound) != INTEGER_CST)
realistic = false;
else
gcc_checking_assert (i_bound == tree_to_double_int (bound));
if (!upper && !realistic)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment