From 506bd24a5d7f73fc9e3f3c612bb51477a1c4ad9c Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 4 Aug 2020 07:16:05 +0200 Subject: [PATCH] Adjust two_valued_val_range_p for irange API. gcc/ChangeLog: * vr-values.c (simplify_using_ranges::two_valued_val_range_p): Use irange API. --- gcc/vr-values.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 38c9a657dad..2fd4956a2e4 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -4194,33 +4194,20 @@ simplify_using_ranges::simplify_internal_call_using_ranges bool simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b) { - const value_range *vr = get_value_range (var); - if (vr->varying_p () - || vr->undefined_p () - || TREE_CODE (vr->min ()) != INTEGER_CST - || TREE_CODE (vr->max ()) != INTEGER_CST) + value_range vr = *get_value_range (var); + vr.normalize_symbolics (); + if (vr.varying_p () || vr.undefined_p ()) return false; - if (vr->kind () == VR_RANGE - && wi::to_wide (vr->max ()) - wi::to_wide (vr->min ()) == 1) - { - *a = vr->min (); - *b = vr->max (); - return true; - } - - /* ~[TYPE_MIN + 1, TYPE_MAX - 1] */ - if (vr->kind () == VR_ANTI_RANGE - && (wi::to_wide (vr->min ()) - - wi::to_wide (vrp_val_min (TREE_TYPE (var)))) == 1 - && (wi::to_wide (vrp_val_max (TREE_TYPE (var))) - - wi::to_wide (vr->max ())) == 1) + if ((vr.num_pairs () == 1 && vr.upper_bound () - vr.lower_bound () == 1) + || (vr.num_pairs () == 2 + && vr.lower_bound (0) == vr.upper_bound (0) + && vr.lower_bound (1) == vr.upper_bound (1))) { - *a = vrp_val_min (TREE_TYPE (var)); - *b = vrp_val_max (TREE_TYPE (var)); + *a = wide_int_to_tree (TREE_TYPE (var), vr.lower_bound ()); + *b = wide_int_to_tree (TREE_TYPE (var), vr.upper_bound ()); return true; } - return false; } -- 2.30.2