Message ID | 20200804063441.517123-3-aldyh@redhat.com |
---|---|
State | New |
Headers | show |
Series | irange API adjustments for various files | expand |
On Tue, Aug 4, 2020 at 8:37 AM Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > gcc/ChangeLog: > > * fold-const.c (expr_not_equal_to): Adjust for irange API. > --- > gcc/fold-const.c | 17 ++++------------- > 1 file changed, 4 insertions(+), 13 deletions(-) > > diff --git a/gcc/fold-const.c b/gcc/fold-const.c > index 1324a194995..5d27927f6bf 100644 > --- a/gcc/fold-const.c > +++ b/gcc/fold-const.c > @@ -10194,8 +10194,7 @@ tree_expr_nonzero_p (tree t) > bool > expr_not_equal_to (tree t, const wide_int &w) > { > - wide_int min, max, nz; > - value_range_kind rtype; > + value_range vr; > switch (TREE_CODE (t)) > { > case INTEGER_CST: > @@ -10204,17 +10203,9 @@ expr_not_equal_to (tree t, const wide_int &w) > case SSA_NAME: > if (!INTEGRAL_TYPE_P (TREE_TYPE (t))) > return false; > - rtype = get_range_info (t, &min, &max); > - if (rtype == VR_RANGE) > - { > - if (wi::lt_p (max, w, TYPE_SIGN (TREE_TYPE (t)))) > - return true; > - if (wi::lt_p (w, min, TYPE_SIGN (TREE_TYPE (t)))) > - return true; > - } > - else if (rtype == VR_ANTI_RANGE > - && wi::le_p (min, w, TYPE_SIGN (TREE_TYPE (t))) > - && wi::le_p (w, max, TYPE_SIGN (TREE_TYPE (t)))) > + get_range_info (t, vr); Ick. Do we now use references for out parameters? I find this highly non-obvious semantics. What's wrong with vr = get_range_info (t); if you dislike get_range_info (t, &vr)? Please reconsider. Richard. > + if (!vr.undefined_p () > + && !vr.contains_p (wide_int_to_tree (TREE_TYPE (t), w))) > return true; > /* If T has some known zero bits and W has any of those bits set, > then T is known not to be equal to W. */ > -- > 2.26.2 >
On 8/4/20 8:52 AM, Richard Biener wrote: > On Tue, Aug 4, 2020 at 8:37 AM Aldy Hernandez via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> gcc/ChangeLog: >> >> * fold-const.c (expr_not_equal_to): Adjust for irange API. >> --- >> gcc/fold-const.c | 17 ++++------------- >> 1 file changed, 4 insertions(+), 13 deletions(-) >> >> diff --git a/gcc/fold-const.c b/gcc/fold-const.c >> index 1324a194995..5d27927f6bf 100644 >> --- a/gcc/fold-const.c >> +++ b/gcc/fold-const.c >> @@ -10194,8 +10194,7 @@ tree_expr_nonzero_p (tree t) >> bool >> expr_not_equal_to (tree t, const wide_int &w) >> { >> - wide_int min, max, nz; >> - value_range_kind rtype; >> + value_range vr; >> switch (TREE_CODE (t)) >> { >> case INTEGER_CST: >> @@ -10204,17 +10203,9 @@ expr_not_equal_to (tree t, const wide_int &w) >> case SSA_NAME: >> if (!INTEGRAL_TYPE_P (TREE_TYPE (t))) >> return false; >> - rtype = get_range_info (t, &min, &max); >> - if (rtype == VR_RANGE) >> - { >> - if (wi::lt_p (max, w, TYPE_SIGN (TREE_TYPE (t)))) >> - return true; >> - if (wi::lt_p (w, min, TYPE_SIGN (TREE_TYPE (t)))) >> - return true; >> - } >> - else if (rtype == VR_ANTI_RANGE >> - && wi::le_p (min, w, TYPE_SIGN (TREE_TYPE (t))) >> - && wi::le_p (w, max, TYPE_SIGN (TREE_TYPE (t)))) >> + get_range_info (t, vr); > > Ick. Do we now use references for out parameters? I find this > highly non-obvious semantics. What's wrong with > > vr = get_range_info (t); > > if you dislike get_range_info (t, &vr)? Using references was decided last year. We want the ability of to use the same range granularity as what the user requested, so we can't just return a range, as we don't know how many sub-ranges the user wants: int_range<10> big_range; twiddle_range(big_range); We want the above to work with big_range, or a small range, or a value_range. Twiddle_range should be range agnostic. get_range_info(const_tree, value_range &) has been available since last year. I suppose if one were so inclined, one could change it to take a pointer to be consistent with the other get_range_info() overload. Aldy
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1324a194995..5d27927f6bf 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10194,8 +10194,7 @@ tree_expr_nonzero_p (tree t) bool expr_not_equal_to (tree t, const wide_int &w) { - wide_int min, max, nz; - value_range_kind rtype; + value_range vr; switch (TREE_CODE (t)) { case INTEGER_CST: @@ -10204,17 +10203,9 @@ expr_not_equal_to (tree t, const wide_int &w) case SSA_NAME: if (!INTEGRAL_TYPE_P (TREE_TYPE (t))) return false; - rtype = get_range_info (t, &min, &max); - if (rtype == VR_RANGE) - { - if (wi::lt_p (max, w, TYPE_SIGN (TREE_TYPE (t)))) - return true; - if (wi::lt_p (w, min, TYPE_SIGN (TREE_TYPE (t)))) - return true; - } - else if (rtype == VR_ANTI_RANGE - && wi::le_p (min, w, TYPE_SIGN (TREE_TYPE (t))) - && wi::le_p (w, max, TYPE_SIGN (TREE_TYPE (t)))) + get_range_info (t, vr); + if (!vr.undefined_p () + && !vr.contains_p (wide_int_to_tree (TREE_TYPE (t), w))) return true; /* If T has some known zero bits and W has any of those bits set, then T is known not to be equal to W. */