Commit 7f17528a by Zdenek Dvorak Committed by Zdenek Dvorak

tree-ssa-loop-niter.c (number_of_iterations_cond): Split into several functions.

	* tree-ssa-loop-niter.c (number_of_iterations_cond): Split into several
	functions.
	(number_of_iterations_ne, number_of_iterations_lt_to_ne,
	assert_no_overflow_lt, assert_loop_rolls_lt, number_of_iterations_lt,
	number_of_iterations_le): New functions.
	(number_of_iterations_special): Removed.
	(number_of_iterations_exit): Do not use number_of_iterations_special.
	* tree.c (unsigned_type_for): Always return integer type.

	* gcc.dg/tree-ssa/pr19210-1.c: Update outcome.  Add new test loop.
	* gcc.dg/tree-ssa/pr19210-2.c: Ditto.

From-SVN: r109702
parent 26fb114d
2006-01-14 Zdenek Dvorak <dvorakz@suse.cz>
* tree-ssa-loop-niter.c (number_of_iterations_cond): Split into several
functions.
(number_of_iterations_ne, number_of_iterations_lt_to_ne,
assert_no_overflow_lt, assert_loop_rolls_lt, number_of_iterations_lt,
number_of_iterations_le): New functions.
(number_of_iterations_special): Removed.
(number_of_iterations_exit): Do not use number_of_iterations_special.
* tree.c (unsigned_type_for): Always return integer type.
2006-01-14 Steven Bosscher <stevenb.gcc@gmail.com> 2006-01-14 Steven Bosscher <stevenb.gcc@gmail.com>
Richard Guenther <rguenther@suse.de> Richard Guenther <rguenther@suse.de>
......
2005-01-14 Zdenek Dvorak <dvorakz@suse.cz>
* gcc.dg/tree-ssa/pr19210-1.c: Update outcome. Add new test loop.
* gcc.dg/tree-ssa/pr19210-2.c: Ditto.
2006-01-14 Steven Bosscher <stevenb.gcc@gmail.com> 2006-01-14 Steven Bosscher <stevenb.gcc@gmail.com>
Richard Guenther <rguenther@suse.de> Richard Guenther <rguenther@suse.de>
...@@ -12,9 +12,18 @@ f (unsigned n) ...@@ -12,9 +12,18 @@ f (unsigned n)
for(k = 0;k <= n;k += 4) /* { dg-warning "cannot optimize.*overflow" } */ for(k = 0;k <= n;k += 4) /* { dg-warning "cannot optimize.*overflow" } */
g(); g();
for(k = 5;k <= n;k += 5) /* { dg-warning "cannot optimize.*overflow" } */ /* We used to get warning for this loop. However, since then # of iterations
analysis improved, and we can now prove that this loop does not verflow.
This is because the only case when it would overflow is if n = ~0 (since
~0 is divisible by 5), and this cannot be the case, since when we got
here, the previous loop exited, thus there exists k > n. */
for(k = 5;k <= n;k += 5)
g(); g();
/* So we need the following loop, instead. */
for(k = 4;k <= n;k += 5) /* { dg-warning "cannot optimize.*overflow" } */
g();
for(k = 15;k >= n;k--) /* { dg-warning "cannot optimize.*infinite" } */ for(k = 15;k >= n;k--) /* { dg-warning "cannot optimize.*infinite" } */
g(); g();
} }
...@@ -12,7 +12,15 @@ f (unsigned n) ...@@ -12,7 +12,15 @@ f (unsigned n)
for(k = 5;k <= n;k += 4) /* { dg-warning "assuming.*not overflow" } */ for(k = 5;k <= n;k += 4) /* { dg-warning "assuming.*not overflow" } */
g(); g();
for(k = 5;k <= n;k += 5) /* { dg-warning "assuming.*not overflow" } */ /* We used to get warning for this loop. However, since then # of iterations
analysis improved, and we can now prove that this loop does not verflow.
This is because the only case when it would overflow is if n = ~0 (since
~0 is divisible by 5), and this cannot be the case, since when we got
here, the previous loop exited, thus there exists k > n. */
for(k = 5;k <= n;k += 5)
g();
for(k = 4;k <= n;k += 5) /* { dg-warning "assuming.*not overflow" } */
g(); g();
for(k = 15;k >= n;k--) /* { dg-warning "assuming.*not infinite" } */ for(k = 15;k >= n;k--) /* { dg-warning "assuming.*not infinite" } */
......
...@@ -6809,6 +6809,8 @@ tree_fold_gcd (tree a, tree b) ...@@ -6809,6 +6809,8 @@ tree_fold_gcd (tree a, tree b)
tree tree
unsigned_type_for (tree type) unsigned_type_for (tree type)
{ {
if (POINTER_TYPE_P (type))
return size_type_node;
return lang_hooks.types.unsigned_type (type); return lang_hooks.types.unsigned_type (type);
} }
......
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