diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-08-04 07:16:05 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2020-08-04 07:25:02 +0200 |
commit | 506bd24a5d7f73fc9e3f3c612bb51477a1c4ad9c (patch) | |
tree | 972d6dcf32eb5b1b0dd40e43dd8c9d9add7eed16 | |
parent | 70be5895658d9da5135957bd9af7b14ba4a82a70 (diff) | |
download | gcc-506bd24a5d7f73fc9e3f3c612bb51477a1c4ad9c.zip gcc-506bd24a5d7f73fc9e3f3c612bb51477a1c4ad9c.tar.gz gcc-506bd24a5d7f73fc9e3f3c612bb51477a1c4ad9c.tar.bz2 |
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.
-rw-r--r-- | gcc/vr-values.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 38c9a65..2fd4956 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; } |