]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/84933 (ICE in set_value_range, at tree-vrp.c:288 since r257852)
authorRichard Biener <rguenther@suse.de>
Mon, 19 Mar 2018 14:11:05 +0000 (14:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 19 Mar 2018 14:11:05 +0000 (14:11 +0000)
2018-03-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84933
* tree-vrp.c (set_and_canonicalize_value_range): Treat out-of-bound
values as -INF/INF when canonicalizing an ANTI_RANGE to a RANGE.

* g++.dg/pr84933.C: New testcase.

From-SVN: r258646

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr84933.C [new file with mode: 0644]
gcc/tree-vrp.c

index b27b28f44ffd59a69fee347c9150e8054b62409b..bc6436748630f484c8c86575d5e0bd9b9420c7ae 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84933
+       * tree-vrp.c (set_and_canonicalize_value_range): Treat out-of-bound
+       values as -INF/INF when canonicalizing an ANTI_RANGE to a RANGE.
+
 2018-03-19  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84859
index 9f462160a61406e0999d9db0656e29da79ed0f1d..5fbedb4e460ee9660e59e2438015c2a00c555ee6 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84933
+       * g++.dg/pr84933.C: New testcase.
+
 2018-03-19  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84859
diff --git a/gcc/testsuite/g++.dg/pr84933.C b/gcc/testsuite/g++.dg/pr84933.C
new file mode 100644 (file)
index 0000000..cbfeb11
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fstrict-enums -fno-inline" } */
+
+enum a {};
+int *d;
+int b, e, f;
+a c, g;
+class h {
+    virtual unsigned i();
+};
+class j : h {
+    unsigned i() {
+       for (;;) {
+           b = c <= 0;
+           if (b)
+             e = *d;
+           b = g && c;
+           if (b)
+             f = *d;
+       }
+    }
+};
+void k() { new j; }
index 625e65b1184c86963f36f0c66a9e56311c99e101..aa53db655762ce33fd3afe423b0bc6e09a180f5b 100644 (file)
@@ -386,8 +386,13 @@ set_and_canonicalize_value_range (value_range *vr, enum value_range_type t,
   /* Anti-ranges that can be represented as ranges should be so.  */
   if (t == VR_ANTI_RANGE)
     {
-      bool is_min = vrp_val_is_min (min);
-      bool is_max = vrp_val_is_max (max);
+      /* For -fstrict-enums we may receive out-of-range ranges so consider
+         values < -INF and values > INF as -INF/INF as well.  */
+      tree type = TREE_TYPE (min);
+      bool is_min = (INTEGRAL_TYPE_P (type)
+                    && tree_int_cst_compare (min, TYPE_MIN_VALUE (type)) <= 0);
+      bool is_max = (INTEGRAL_TYPE_P (type)
+                    && tree_int_cst_compare (max, TYPE_MAX_VALUE (type)) >= 0);
 
       if (is_min && is_max)
        {
This page took 0.086461 seconds and 5 git commands to generate.