From e4722b81a45e797565b700d1a5af9b66ae56adf0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 12 Nov 2019 09:21:40 +0100 Subject: [PATCH] re PR tree-optimization/92452 (ICE in vrp_prop::check_array_ref at tree-vrp.c:4153) 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 | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/pr92452.c | 5 +++++ gcc/tree-vrp.c | 7 +++++-- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/pr92452.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77ede4d..39c9f6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-11-12 Jakub Jelinek + + 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 * tree-vect-loop.c (vect_transform_loop): Don't overwrite epilogues diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ef92af..2196bf0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-12 Jakub Jelinek + + PR tree-optimization/92452 + * c-c++-common/pr92452.c: New test. + 2019-11-12 Andre Vieira * 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 index 0000000..8c12b67 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr92452.c @@ -0,0 +1,5 @@ +/* PR tree-optimization/92452 */ +/* { dg-do compile } */ +/* { dg-options "-Os -Warray-bounds=1" } */ + +#include "pr60101.c" diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index b8b6967..da11dfb 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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 -- 2.7.4