]> gcc.gnu.org Git - gcc.git/commitdiff
re PR middle-end/41043 (virtual memory exhausted: Cannot allocate memory)
authorRichard Guenther <rguenther@suse.de>
Tue, 16 Feb 2010 16:11:28 +0000 (16:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 16 Feb 2010 16:11:28 +0000 (16:11 +0000)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wstrict-overflow-18.c
gcc/tree-vrp.c

index 4495a31099733f19deec46c20903a99fa0c5902b..eaa030f49ebabf2fd696e96a0915a51054097988 100644 (file)
@@ -1,3 +1,12 @@
+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
index fa0ac072019df8afea673c135cbf74324ba91c0f..c70a97982486a06c3adbb37b616f59112719b736 100644 (file)
@@ -1,3 +1,9 @@
+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.
index e26e7e914e5e2f3d052833ed49751427d345fe0d..2767c44fbf24af2f5e3dbb2c833fe1d0bc5caf02 100644 (file)
@@ -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);
     }
index 81645485f8b2dd65da83e8e356d57a2855d0a89e..2f0f05965c1bb6688876ccecc0d5b886ede6e7b3 100644 (file)
@@ -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;
 
This page took 0.074488 seconds and 5 git commands to generate.