From 4177437ead62c0c74d560f3611b3583078f59688 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 19 May 2016 15:45:35 +0000 Subject: [PATCH] re PR tree-optimization/71031 (ICE in extract_range_from_binary_expr_1, at tree-vrp.c:2535 w/ -Os) 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 | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/tree-ssa/vrp100.c | 32 ++++++++++++++++++++++++++ gcc/tree-vrp.c | 17 +++++++------- 4 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vrp100.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 883892bc1f9..4900c7e2d46 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-05-19 Marek Polacek + + 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 * tree-vect-stmts.c (vectorizable_simd_clone_call): Utilize diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b071e9f5a05..f9ea24016ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-19 Marek Polacek + + PR tree-optimization/71031 + * gcc.dg/tree-ssa/vrp100.c: New test. + 2016-05-19 Ilya Enkovich 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 index 00000000000..c0fe4b50963 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp100.c @@ -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; + } + } + } +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 69e6248a4fc..92d889cd1e2 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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 { -- 2.30.2