Commit b09bae68 by Richard Guenther Committed by Richard Biener

re PR middle-end/41043 (virtual memory exhausted: Cannot allocate memory)

2010-02-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/41043
	* tree-vrp.c  (vrp_var_may_overflow): Only ask SCEV for
	real loops.
	(vrp_visit_assignment_or_call): Do not ask SCEV for regular
	statements ...
	(vrp_visit_phi_node): ... but only for loop PHI nodes.

	* gfortran.dg/pr41043.f90: New testcase.
	* gcc.dg/Wstrict-overflow-18.c: XFAIL.

From-SVN: r156808
parent d779a591
2010-02-16 Richard Guenther <rguenther@suse.de>
PR tree-optimization/41043
* tree-vrp.c (vrp_var_may_overflow): Only ask SCEV for
real loops.
(vrp_visit_assignment_or_call): Do not ask SCEV for regular
statements ...
(vrp_visit_phi_node): ... but only for loop PHI nodes.
2010-02-16 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/43074
......
2010-02-16 Richard Guenther <rguenther@suse.de>
PR tree-optimization/41043
* gfortran.dg/pr41043.f90: New testcase.
* gcc.dg/Wstrict-overflow-18.c: XFAIL.
2010-02-16 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist-opt.C: Declare max_val inline.
......
......@@ -2,7 +2,10 @@
/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
/* Don't warn about an overflow when folding i > 0. The loop analysis
should determine that i does not wrap. */
should determine that i does not wrap.
The test is really bogus, p->a - p->b can be larger than INT_MAX
and thus i can very well wrap. */
struct c { unsigned int a; unsigned int b; };
extern void bar (struct c *);
......@@ -14,7 +17,7 @@ foo (struct c *p)
for (i = 0; i < p->a - p->b; ++i)
{
if (i > 0)
if (i > 0) /* { dg-bogus "warning" "" { xfail *-*-* } } */
sum += 2;
bar (p);
}
......
......@@ -3280,7 +3280,8 @@ vrp_var_may_overflow (tree var, gimple stmt)
return true;
l = loop_containing_stmt (stmt);
if (l == NULL)
if (l == NULL
|| !loop_outer (l))
return true;
chrec = instantiate_parameters (l, analyze_scalar_evolution (l, var));
......@@ -5342,7 +5343,6 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
&& TYPE_MAX_VALUE (TREE_TYPE (lhs)))
|| POINTER_TYPE_P (TREE_TYPE (lhs))))
{
struct loop *l;
value_range_t new_vr = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
if (code == GIMPLE_CALL)
......@@ -5350,12 +5350,6 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
else
extract_range_from_assignment (&new_vr, stmt);
/* If STMT is inside a loop, we may be able to know something
else about the range of LHS by examining scalar evolution
information. */
if (current_loops && (l = loop_containing_stmt (stmt)))
adjust_range_with_scev (&new_vr, l, stmt, lhs);
if (update_value_range (lhs, &new_vr))
{
*output_p = lhs;
......@@ -6259,6 +6253,7 @@ vrp_visit_phi_node (gimple phi)
value_range_t *lhs_vr = get_value_range (lhs);
value_range_t vr_result = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
int edges, old_edges;
struct loop *l;
copy_value_range (&vr_result, lhs_vr);
......@@ -6322,6 +6317,14 @@ vrp_visit_phi_node (gimple phi)
}
}
/* If this is a loop PHI node SCEV may known more about its
value-range.
??? Identify loop PHI nodes properly. */
if (current_loops
&& (l = loop_containing_stmt (phi))
&& loop_outer (l))
adjust_range_with_scev (&vr_result, l, phi, lhs);
if (vr_result.type == VR_VARYING)
goto varying;
......
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