From 9c3cb3607913d35e96243a26b1ad4aaee1ad8a68 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 27 Apr 2015 13:26:12 +0200 Subject: [PATCH] re PR tree-optimization/65875 (ICE: Segmentation fault) PR tree-optimization/65875 * tree-vrp.c (update_value_range): If in is_new case setting old_vr to VR_VARYING, also set new_vr to it. Remove old_vr->type == VR_VARYING test. (vrp_visit_phi_node): Return SSA_PROP_VARYING instead of SSA_PROP_INTERESTING if update_value_range returned true, but new range is VR_VARYING. * gcc.c-torture/compile/pr65875.c: New test. From-SVN: r222458 --- gcc/ChangeLog | 10 ++++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.c-torture/compile/pr65875.c | 24 +++++++++++++++++++ gcc/tree-vrp.c | 18 ++++++++++---- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr65875.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ceb6dc361bd..ea2fb2a8458 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-04-27 Jakub Jelinek + + PR tree-optimization/65875 + * tree-vrp.c (update_value_range): If in is_new case setting + old_vr to VR_VARYING, also set new_vr to it. Remove + old_vr->type == VR_VARYING test. + (vrp_visit_phi_node): Return SSA_PROP_VARYING instead of + SSA_PROP_INTERESTING if update_value_range returned true, + but new range is VR_VARYING. + 2015-04-27 Thomas Preud'homme * combine.c (sign_extend_short_imm): New. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18a56e868df..c25b518b22b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-27 Jakub Jelinek + + PR tree-optimization/65875 + * gcc.c-torture/compile/pr65875.c: New test. + 2015-04-25 Marek Polacek PR c/52085 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65875.c b/gcc/testsuite/gcc.c-torture/compile/pr65875.c new file mode 100644 index 00000000000..26d2a25e9ef --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr65875.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/65875 */ + +int a, b, c, d, e, f, g; + +void +foo (void) +{ + long h = 0, i; + if (g < 0) + i = -g; + for (; b;) + for (; c;) + if (e) + h = 1; + for (; f;) + if (a) + break; + if (h > i) + while (h > i) + { + d = 0; + h--; + } +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index e7ab23c0c0b..0ade55c0b54 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -886,13 +886,18 @@ update_value_range (const_tree var, value_range_t *new_vr) if (is_new) { /* Do not allow transitions up the lattice. The following - is slightly more awkward than just new_vr->type < old_vr->type + is slightly more awkward than just new_vr->type < old_vr->type because VR_RANGE and VR_ANTI_RANGE need to be considered the same. We may not have is_new when transitioning to - UNDEFINED or from VARYING. */ - if (new_vr->type == VR_UNDEFINED - || old_vr->type == VR_VARYING) - set_value_range_to_varying (old_vr); + UNDEFINED. If old_vr->type is VARYING, we shouldn't be + called. */ + if (new_vr->type == VR_UNDEFINED) + { + BITMAP_FREE (new_vr->equiv); + set_value_range_to_varying (old_vr); + set_value_range_to_varying (new_vr); + return true; + } else set_value_range (old_vr, new_vr->type, new_vr->min, new_vr->max, new_vr->equiv); @@ -8941,6 +8946,9 @@ update_range: fprintf (dump_file, "\n"); } + if (vr_result.type == VR_VARYING) + return SSA_PROP_VARYING; + return SSA_PROP_INTERESTING; } -- 2.30.2