re PR tree-optimization/92452 (ICE in vrp_prop::check_array_ref at tree-vrp.c:4153)
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Nov 2019 08:21:40 +0000 (09:21 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Nov 2019 08:21:40 +0000 (09:21 +0100)
PR tree-optimization/92452
* tree-vrp.c (vrp_prop::check_array_ref): If TRUNC_DIV_EXPR folds
into NULL_TREE, set up_bound to NULL_TREE instead of computing
MINUS_EXPR on it.

* c-c++-common/pr92452.c: New test.

From-SVN: r278080

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr92452.c [new file with mode: 0644]
gcc/tree-vrp.c

index 77ede4d..39c9f6f 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92452
+       * tree-vrp.c (vrp_prop::check_array_ref): If TRUNC_DIV_EXPR folds
+       into NULL_TREE, set up_bound to NULL_TREE instead of computing
+       MINUS_EXPR on it.
+
 2019-11-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * tree-vect-loop.c (vect_transform_loop): Don't overwrite epilogues
index 1ef92af..2196bf0 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92452
+       * c-c++-common/pr92452.c: New test.
+
 2019-11-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * gcc.dg/vect/pr92347.c: New test.
diff --git a/gcc/testsuite/c-c++-common/pr92452.c b/gcc/testsuite/c-c++-common/pr92452.c
new file mode 100644 (file)
index 0000000..8c12b67
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR tree-optimization/92452 */
+/* { dg-do compile } */
+/* { dg-options "-Os -Warray-bounds=1" } */
+
+#include "pr60101.c"
index b8b6967..da11dfb 100644 (file)
@@ -4150,8 +4150,11 @@ vrp_prop::check_array_ref (location_t location, tree ref,
 
          up_bound_p1 = int_const_binop (TRUNC_DIV_EXPR, maxbound, eltsize);
 
-         up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
-                                     build_int_cst (ptrdiff_type_node, 1));
+         if (up_bound_p1 != NULL_TREE)
+           up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
+                                       build_int_cst (ptrdiff_type_node, 1));
+         else
+           up_bound = NULL_TREE;
        }
     }
   else