Commit 7136db7a by Richard Guenther Committed by Richard Biener

re PR tree-optimization/27603 (wrong code, apparently due to bad VRP (-O2))

2006-05-15  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27603
	* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
	Do computations in original type.

	* gcc.dg/torture/pr27603.c: New testcase.

From-SVN: r113797
parent b6398823
2006-05-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/27603
* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
Do computations in original type.
2006-05-15 Mircea Namolaru <namolaru@il.ibm.com> 2006-05-15 Mircea Namolaru <namolaru@il.ibm.com>
* see.c: Code style changes such as redundant paranthesis, * see.c: Code style changes such as redundant paranthesis,
......
2006-05-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/27603
* gcc.dg/torture/pr27603.c: New testcase.
2006-05-15 Paul Thomas <pault@gcc.gnu.org> 2006-05-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/25090 PR fortran/25090
/* { dg-do run } */
void exit (int);
void abort (void);
int a;
int main()
{
int j;
for (j = 0; j < 6; j++)
{
if ((unsigned)j - 3 <= 1)
exit (0);
a = 1000 * (6 - j);
}
abort ();
}
...@@ -1587,7 +1587,6 @@ infer_loop_bounds_from_undefined (struct loop *loop) ...@@ -1587,7 +1587,6 @@ infer_loop_bounds_from_undefined (struct loop *loop)
tree scev = instantiate_parameters tree scev = instantiate_parameters
(loop, analyze_scalar_evolution (loop, op0)); (loop, analyze_scalar_evolution (loop, op0));
tree type = chrec_type (scev); tree type = chrec_type (scev);
tree utype;
if (chrec_contains_undetermined (scev) if (chrec_contains_undetermined (scev)
|| TYPE_UNSIGNED (type)) || TYPE_UNSIGNED (type))
...@@ -1604,20 +1603,23 @@ infer_loop_bounds_from_undefined (struct loop *loop) ...@@ -1604,20 +1603,23 @@ infer_loop_bounds_from_undefined (struct loop *loop)
|| TYPE_MAX_VALUE (type) == NULL_TREE) || TYPE_MAX_VALUE (type) == NULL_TREE)
break; break;
utype = unsigned_type_for (type); if (integer_nonzerop (step))
if (tree_int_cst_lt (step, integer_zero_node))
diff = fold_build2 (MINUS_EXPR, utype, init,
TYPE_MIN_VALUE (type));
else
diff = fold_build2 (MINUS_EXPR, utype,
TYPE_MAX_VALUE (type), init);
if (!integer_zerop (step))
{ {
estimation = fold_build2 (CEIL_DIV_EXPR, utype, diff, tree utype;
if (tree_int_cst_lt (step, integer_zero_node))
diff = fold_build2 (MINUS_EXPR, type, init,
TYPE_MIN_VALUE (type));
else
diff = fold_build2 (MINUS_EXPR, type,
TYPE_MAX_VALUE (type), init);
utype = unsigned_type_for (type);
estimation = fold_build2 (CEIL_DIV_EXPR, type, diff,
step); step);
record_estimate (loop, estimation, boolean_true_node, record_estimate (loop,
stmt); fold_convert (utype, estimation),
boolean_true_node, stmt);
} }
} }
......
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