From a257ad466894df673adc46865d763ee4324d9e17 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 28 Nov 2018 13:04:27 +0000 Subject: [PATCH] re PR tree-optimization/88217 (Compile time and memory hog w/ -O2 -fstrict-enums -fno-tree-forwprop -fno-tree-fre) 2018-11-28 Richard Biener PR tree-optimization/88217 * vr-values.c (vr_values::extract_range_from_phi_node): Make sure to handle results > +INF and < -INF correctly when trying to drop down to +INF - 1 or -INF + 1. * g++.dg/pr88217.C: New testcase. From-SVN: r266557 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr88217.C | 18 ++++++++++++++++++ gcc/vr-values.c | 6 ++++-- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr88217.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33739adf674..2c5bfffb5ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-11-28 Richard Biener + + PR tree-optimization/88217 + * vr-values.c (vr_values::extract_range_from_phi_node): Make + sure to handle results > +INF and < -INF correctly when + trying to drop down to +INF - 1 or -INF + 1. + 2018-11-28 Alan Modra * xcoffout.c (do_block): Signed/unsigned warning fix. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c9a77e08da..9f2383a38c3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-28 Richard Biener + + PR tree-optimization/88217 + * g++.dg/pr88217.C: New testcase. + 2018-11-28 Richard Biener PR tree-optimization/79351 diff --git a/gcc/testsuite/g++.dg/pr88217.C b/gcc/testsuite/g++.dg/pr88217.C new file mode 100644 index 00000000000..b0506acabd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr88217.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -fstrict-enums -fno-tree-forwprop -fno-tree-fre" } + +extern "C" int printf (const char *, ...); + +enum E { e1, e2, e3, X }; +E operator*(E e) { return e; } +E begin(E e) { return e; } +E end(E e) { return X; } +E operator++(E& e) { return e = E(e+1); } + +int main() +{ + for (auto e: e1) + { + printf ("%d ", e); + } +} diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 41862b97601..a0027c0b353 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -2857,7 +2857,8 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result) if (cmp_min < 0) new_min = lhs_vr->min (); else if (cmp_min > 0 - && !vrp_val_is_min (vr_result->min ())) + && tree_int_cst_lt (vrp_val_min (vr_result->type ()), + vr_result->min ())) new_min = int_const_binop (PLUS_EXPR, vrp_val_min (vr_result->type ()), build_int_cst (vr_result->type (), 1)); @@ -2866,7 +2867,8 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result) if (cmp_max > 0) new_max = lhs_vr->max (); else if (cmp_max < 0 - && !vrp_val_is_max (vr_result->max ())) + && tree_int_cst_lt (vr_result->max (), + vrp_val_max (vr_result->type ()))) new_max = int_const_binop (MINUS_EXPR, vrp_val_max (vr_result->type ()), build_int_cst (vr_result->type (), 1)); -- 2.30.2