From ad2a47a557fc500553d32b03f84458d2c5beadfc Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 25 May 2006 07:42:28 +0000 Subject: [PATCH] * tree-vrp.c (extract_range_from_assert): Set the range to VARYING for LT and GT if the computed range is effectively empty. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114108 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 ++++++- gcc/tree-vrp.c | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d94f8d6837c..64117ca1d5c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,9 @@ -2006-06-24 John David Anglin +2006-05-25 Eric Botcazou + + * tree-vrp.c (extract_range_from_assert): Set the range to VARYING + for LT and GT if the computed range is effectively empty. + +2006-05-24 John David Anglin PR target/27627 * pa/pa-modes.def: Use mips_single_format, mips_double_format and diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 11c8077b825..3ac01fb70f3 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -939,14 +939,22 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) max = limit_vr->max; } - /* For LT_EXPR, we create the range [MIN, MAX - 1]. */ - if (cond_code == LT_EXPR) + /* If the maximum value forces us to be out of bounds, simply punt. + It would be pointless to try and do anything more since this + all should be optimized away above us. */ + if (cond_code == LT_EXPR && compare_values (max, min) == 0) + set_value_range_to_varying (vr_p); + else { - tree one = build_int_cst (type, 1); - max = fold_build2 (MINUS_EXPR, type, max, one); - } + /* For LT_EXPR, we create the range [MIN, MAX - 1]. */ + if (cond_code == LT_EXPR) + { + tree one = build_int_cst (type, 1); + max = fold_build2 (MINUS_EXPR, type, max, one); + } - set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv); + set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv); + } } else if (cond_code == GE_EXPR || cond_code == GT_EXPR) { @@ -962,14 +970,22 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) min = limit_vr->min; } - /* For GT_EXPR, we create the range [MIN + 1, MAX]. */ - if (cond_code == GT_EXPR) + /* If the minimum value forces us to be out of bounds, simply punt. + It would be pointless to try and do anything more since this + all should be optimized away above us. */ + if (cond_code == GT_EXPR && compare_values (min, max) == 0) + set_value_range_to_varying (vr_p); + else { - tree one = build_int_cst (type, 1); - min = fold_build2 (PLUS_EXPR, type, min, one); - } + /* For GT_EXPR, we create the range [MIN + 1, MAX]. */ + if (cond_code == GT_EXPR) + { + tree one = build_int_cst (type, 1); + min = fold_build2 (PLUS_EXPR, type, min, one); + } - set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv); + set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv); + } } else gcc_unreachable (); -- 2.11.4.GIT