re PR tree-optimization/71031 (ICE in extract_range_from_binary_expr_1, at tree-vrp...
authorMarek Polacek <polacek@redhat.com>
Thu, 19 May 2016 15:45:35 +0000 (15:45 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 19 May 2016 15:45:35 +0000 (15:45 +0000)
PR tree-optimization/71031
* tree-vrp.c (extract_range_from_binary_expr_1): Turn assert into a
condition and adjust the code a bit.

* gcc.dg/tree-ssa/vrp100.c: New test.

From-SVN: r236477

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp100.c [new file with mode: 0644]
gcc/tree-vrp.c

index 883892bc1f925ed92c3067041ea5b999b359a2f4..4900c7e2d4643f8aa6ab5eea945620e844b88da5 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-19  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/71031
+       * tree-vrp.c (extract_range_from_binary_expr_1): Turn assert into a
+       condition and adjust the code a bit.
+
 2016-05-19  Martin Liska  <mliska@suse.cz>
 
        * tree-vect-stmts.c (vectorizable_simd_clone_call): Utilize
index b071e9f5a05f2180967899e65a57474a041b8ecc..f9ea24016ca2e9f9ff97d832b120dc74d469606c 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-19  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/71031
+       * gcc.dg/tree-ssa/vrp100.c: New test.
+
 2016-05-19  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        PR rtl-optimization/71148
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp100.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp100.c
new file mode 100644 (file)
index 0000000..c0fe4b5
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR tree-optimization/71031 */
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+int zj;
+int **yr;
+
+void
+nn (void)
+{
+  unsigned int od = 4;
+
+  for (;;)
+    {
+      int lk;
+
+      for (lk = 0; lk < 2; ++lk)
+        {
+          static int cm;
+
+          zj = 0;
+          if (od == 0)
+            return;
+          ++od;
+          for (cm = 0; cm < 2; ++cm)
+            {
+              --od;
+              **yr = 0;
+            }
+        }
+    }
+}
index 69e6248a4fcd63ee1a44f934d0859647d7466a83..92d889cd1e2e0d18924dd1f4c4cb48d587a15b80 100644 (file)
@@ -2519,20 +2519,13 @@ extract_range_from_binary_expr_1 (value_range *vr,
                  min = wide_int_to_tree (expr_type, tmin);
                  max = wide_int_to_tree (expr_type, tmax);
                }
-             else if (min_ovf == -1 && max_ovf == 1)
-               {
-                 /* Underflow and overflow, drop to VR_VARYING.  */
-                 set_value_range_to_varying (vr);
-                 return;
-               }
-             else
+             else if ((min_ovf == -1 && max_ovf == 0)
+                      || (max_ovf == 1 && min_ovf == 0))
                {
                  /* Min underflow or max overflow.  The range kind
                     changes to VR_ANTI_RANGE.  */
                  bool covers = false;
                  wide_int tem = tmin;
-                 gcc_assert ((min_ovf == -1 && max_ovf == 0)
-                             || (max_ovf == 1 && min_ovf == 0));
                  type = VR_ANTI_RANGE;
                  tmin = tmax + 1;
                  if (wi::cmp (tmin, tmax, sgn) < 0)
@@ -2551,6 +2544,12 @@ extract_range_from_binary_expr_1 (value_range *vr,
                  min = wide_int_to_tree (expr_type, tmin);
                  max = wide_int_to_tree (expr_type, tmax);
                }
+             else
+               {
+                 /* Other underflow and/or overflow, drop to VR_VARYING.  */
+                 set_value_range_to_varying (vr);
+                 return;
+               }
            }
          else
            {