From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] range-op-float: Improve multiplication reverse operation
Date: Mon, 5 Dec 2022 14:29:36 +0100 [thread overview]
Message-ID: <32b96813-616d-ba73-811f-8a36e70f9ecd@redhat.com> (raw)
In-Reply-To: <Y43dD0/eSrUNx/8Z@tucnak>
On 12/5/22 12:59, Jakub Jelinek wrote:
> On Mon, Dec 05, 2022 at 10:54:41AM +0100, Aldy Hernandez wrote:
>>> Do you mind if I try that incrementally and only if it doesn't make the
>>> code too large/too unreadable?
>>
>> Sure. And don't feel obligated to implement it either. range-ops is a
>> never ending pit of possible optimizations. We found that out quite early
>> in the design.
>>
>> If you don't get to it, could you at least add a comment?
>
> So like this for multiplication op1/2_range if it passes bootstrap/regtest?
> For division I'll need to go to a drawing board...
Sure, looks good to me.
>
> 2022-12-05 Jakub Jelinek <jakub@redhat.com>
>
> * range-op-float.cc (zero_to_max_range): New function.
> (foperator_plus::op1_range): If lhs can't be INF nor NAN,
> op1 can't be INF.
>
> --- gcc/range-op-float.cc.jj 2022-12-05 11:17:34.900573272 +0100
> +++ gcc/range-op-float.cc 2022-12-05 12:32:30.286753929 +0100
> @@ -2004,6 +2004,29 @@ zero_to_inf_range (REAL_VALUE_TYPE &lb,
> }
> }
>
> +// Set [lb, ub] to [-MAX, -0], [-MAX, +MAX] or [+0, +MAX] depending on
> +// signbit_known.
> +static void
> +zero_to_max_range (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, tree type,
> + int signbit_known)
My apologies for having to passs around [lb, ub] everywhere. At least
for rv_fold(), I'd like to rewrite it next year as:
void rv_fold (frange &r, tree type, ...);
...instead of having to pass LB, UB, and maybe_nan as references. All
the information in LB, UB, and maybe_nan can fit nicely in an frange.
This is what we do in irange (wi_fold). It also sets us up nicely for
when we have subranges, and we can union the result.
I'll clean it up early next release.
Aldy
> +{
> + if (signbit_known > 0)
> + {
> + lb = dconst0;
> + ub = real_max_representable (type);
> + }
> + else if (signbit_known < 0)
> + {
> + lb = real_min_representable (type);
> + ub = real_value_negate (&dconst0);
> + }
> + else
> + {
> + lb = real_min_representable (type);
> + ub = real_max_representable (type);
> + }
> +}
> +
> class foperator_plus : public range_operator_float
> {
> using range_operator_float::op1_range;
> @@ -2159,7 +2182,14 @@ public:
> // and perhaps if it can be NAN or not.
> REAL_VALUE_TYPE lb, ub;
> int signbit_known = signbit_known_p (lhs_lb, lhs_ub, op2_lb, op2_ub);
> - zero_to_inf_range (lb, ub, signbit_known);
> + // If lhs can't be +-INF nor NAN, then op1 can't be +-INF -
> + // +-INF * anything is either +-INF or NAN (if op2 is +-0 or NAN).
> + if (!real_isinf (&lhs_lb)
> + && !real_isinf (&lhs_ub)
> + && !lhs.maybe_isnan ())
> + zero_to_max_range (lb, ub, type, signbit_known);
> + else
> + zero_to_inf_range (lb, ub, signbit_known);
> r.set (type, lb, ub);
> }
> // Otherwise, if op2 is a singleton INF and lhs doesn't include INF,
>
>
> Jakub
>
next prev parent reply other threads:[~2022-12-05 13:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 9:43 [PATCH] range-op-float: Fix up multiplication and division reverse operation [PR107879] Jakub Jelinek
2022-12-05 9:20 ` Aldy Hernandez
2022-12-05 9:37 ` Jakub Jelinek
2022-12-05 9:54 ` Aldy Hernandez
2022-12-05 11:59 ` [PATCH] range-op-float: Improve multiplication reverse operation Jakub Jelinek
2022-12-05 13:29 ` Aldy Hernandez [this message]
2022-12-05 15:33 ` [PATCH] range-op-float: Improve binary reverse operations Jakub Jelinek
2022-12-05 20:43 ` Andrew MacLeod
2022-12-05 20:54 ` Jakub Jelinek
2022-12-05 22:38 ` Jakub Jelinek
2022-12-05 23:49 ` Andrew MacLeod
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32b96813-616d-ba73-811f-8a36e70f9ecd@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).