Message ID | 20200804063441.517123-7-aldyh@redhat.com |
---|---|
State | New |
Headers | show |
Series | irange API adjustments for various files | expand |
On Tue, Aug 4, 2020 at 8:40 AM Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > gcc/ChangeLog: > > * vr-values.c (test_for_singularity): Use irange API. > (simplify_using_ranges::simplify_cond_using_ranges_1): Do not > special case VR_RANGE. > --- > gcc/vr-values.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/gcc/vr-values.c b/gcc/vr-values.c > index 90ba8fca246..e78b25596b0 100644 > --- a/gcc/vr-values.c > +++ b/gcc/vr-values.c > @@ -3480,10 +3480,13 @@ test_for_singularity (enum tree_code cond_code, tree op0, > value range information we have for op0. */ > if (min && max) > { > - if (compare_values (vr->min (), min) == 1) > - min = vr->min (); > - if (compare_values (vr->max (), max) == -1) > - max = vr->max (); > + tree type = TREE_TYPE (op0); > + tree tmin = wide_int_to_tree (type, vr->lower_bound ()); > + tree tmax = wide_int_to_tree (type, vr->upper_bound ()); I guess with symbolic ranges this just doesn't work anymore (or rather will give a pessimistinc upper/lower bound)? > + if (compare_values (tmin, min) == 1) > + min = tmin; > + if (compare_values (tmax, max) == -1) > + max = tmax; > > /* If the new min/max values have converged to a single value, > then there is only one value which can satisfy the condition, > @@ -3594,7 +3597,7 @@ simplify_using_ranges::simplify_cond_using_ranges_1 (gcond *stmt) > > /* If we have range information for OP0, then we might be > able to simplify this conditional. */ > - if (vr->kind () == VR_RANGE) > + if (!vr->undefined_p () && !vr->varying_p ()) > { > tree new_tree = test_for_singularity (cond_code, op0, op1, vr); > if (new_tree) > -- > 2.26.2 >
On 8/4/20 8:58 AM, Richard Biener wrote: > On Tue, Aug 4, 2020 at 8:40 AM Aldy Hernandez via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> gcc/ChangeLog: >> >> * vr-values.c (test_for_singularity): Use irange API. >> (simplify_using_ranges::simplify_cond_using_ranges_1): Do not >> special case VR_RANGE. >> --- >> gcc/vr-values.c | 13 ++++++++----- >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/gcc/vr-values.c b/gcc/vr-values.c >> index 90ba8fca246..e78b25596b0 100644 >> --- a/gcc/vr-values.c >> +++ b/gcc/vr-values.c >> @@ -3480,10 +3480,13 @@ test_for_singularity (enum tree_code cond_code, tree op0, >> value range information we have for op0. */ >> if (min && max) >> { >> - if (compare_values (vr->min (), min) == 1) >> - min = vr->min (); >> - if (compare_values (vr->max (), max) == -1) >> - max = vr->max (); >> + tree type = TREE_TYPE (op0); >> + tree tmin = wide_int_to_tree (type, vr->lower_bound ()); >> + tree tmax = wide_int_to_tree (type, vr->upper_bound ()); > > I guess with symbolic ranges this just doesn't work anymore > (or rather will give a pessimistinc upper/lower bound)? Yes, though we do slightly better than VARYING. The symbolic normalizing code will rewrite [SYM, 5] as [-INF, 5], etc. When I implemented this originally in the ranger branch, I pessimistically downgraded all symbolics to [MIN,MAX] to see if there was any difference in the generated code. There wasn't. I think most of vr-values.c does no better without symbolics, with the exception of compare_value* and the corresponding code that handles comparisons and equivalences. Aldy
diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 90ba8fca246..e78b25596b0 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -3480,10 +3480,13 @@ test_for_singularity (enum tree_code cond_code, tree op0, value range information we have for op0. */ if (min && max) { - if (compare_values (vr->min (), min) == 1) - min = vr->min (); - if (compare_values (vr->max (), max) == -1) - max = vr->max (); + tree type = TREE_TYPE (op0); + tree tmin = wide_int_to_tree (type, vr->lower_bound ()); + tree tmax = wide_int_to_tree (type, vr->upper_bound ()); + if (compare_values (tmin, min) == 1) + min = tmin; + if (compare_values (tmax, max) == -1) + max = tmax; /* If the new min/max values have converged to a single value, then there is only one value which can satisfy the condition, @@ -3594,7 +3597,7 @@ simplify_using_ranges::simplify_cond_using_ranges_1 (gcond *stmt) /* If we have range information for OP0, then we might be able to simplify this conditional. */ - if (vr->kind () == VR_RANGE) + if (!vr->undefined_p () && !vr->varying_p ()) { tree new_tree = test_for_singularity (cond_code, op0, op1, vr); if (new_tree)