From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
gcc-patches@gcc.gnu.org, Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] range-op-float: Fix up -ffinite-math-only range extension and don't extend into infinities [PR109008]
Date: Tue, 21 Mar 2023 14:49:49 +0100 [thread overview]
Message-ID: <f58bf13e-6e3a-1838-90ae-13e5e005f6ec@redhat.com> (raw)
In-Reply-To: <ZBmzks4PngpEjq1s@tucnak>
On 3/21/23 14:39, Jakub Jelinek wrote:
> On Tue, Mar 21, 2023 at 02:28:31PM +0100, Aldy Hernandez wrote:
>>> /* Temporarily disable -ffinite-math-only, so that frange::set doesn't
>>> reduce the range back to real_min_representable (type) as lower bound
>>> or real_max_representable (type) as upper bound. */
>>> bool save_flag_finite_math_only = flag_finite_math_only;
>>> flag_finite_math_only = false;
>>> ret.set (type, lb, ub);
>>> if (lhs.kind () != VR_VARYING)
>>> {
>>> ret.clear_nan ();
>>> ret.union_ (lhs);
>>> }
>>> flag_finite_math_only = save_flag_finite_math_only;
>>
>> It looks like what you want to do is be able to create a range with a known
>> NAN state, but without the setter reducing the range to
>> min/max_representable.
>>
>> How about we enhance the API to provide:
>>
>> 1. Constructor with a known NAN state.
>> 2. Setter with a flag to keep it from canonicalizing into
>> min/max_representable.
>>
>> The flag in 2 could in the future be saved in the frange object to keep
>> union and friends from further canonicalization.
>>
>> So the above could be written as:
>>
>> // Construct [lb, ub] with a known NAN state.
>> frange tmp (lb, ub, lhs.get_nan_state ());
>>
>> // Set RET without dropping/reducing the range to MIN/MAX.
>> ret.set (tmp, FRANGE_FLAG_NO_REPRESENTABLE_REDUCTION);
>>
>> An alternative is to allow the setter to set everything:
>>
>> ret.set (type, lb, ub,
>> lhs.get_nan_state (),
>> FRANGE_FLAG_NO_REPRESENTABLE_REDUCTION);
>>
>> Would this work? I'd be happy to whip up something this week, or if
>> preferred, leave it to the next release.
>
> The latter would be better, I really don't need a temporary range in that
> spot, the union_ is only to copy the NaN state.
> Though, I think right now set actually doesn't do reduction to representable
> at all, all it does is equality compare bounds against the applicable
> boundaries and if both are equal and NaN state is appropriate, change it
> into VR_VARYING.
> So maybe for now all we need is the 4 argument set.
So, this?
frange::set (tree type,
const REAL_VALUE_TYPE &min,
const REAL_VALUE_TYPE &max,
const nan_state &,
value_range_kind kind = VR_RANGE)
If so, I'll start poking at it.
Aldy
next prev parent reply other threads:[~2023-03-21 13:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 8:07 Jakub Jelinek
2023-03-10 8:53 ` Richard Biener
2023-03-10 10:29 ` Jakub Jelinek
2023-03-13 7:18 ` Aldy Hernandez
2023-03-13 7:50 ` Richard Biener
2023-03-13 7:59 ` Aldy Hernandez
2023-03-13 8:06 ` Jakub Jelinek
2023-03-13 8:41 ` Aldy Hernandez
2023-03-20 16:14 ` Jakub Jelinek
2023-03-21 12:56 ` Aldy Hernandez
2023-03-21 13:28 ` Aldy Hernandez
2023-03-21 13:39 ` Jakub Jelinek
2023-03-21 13:49 ` Aldy Hernandez [this message]
2023-03-21 13:56 ` Jakub Jelinek
2023-03-22 6:32 ` Aldy Hernandez
2023-03-22 8:35 ` Jakub Jelinek
2023-03-28 7:54 ` [PATCH] range-op-float: Use get_nan_state in float_widen_lhs_range Jakub Jelinek
2023-03-28 8:50 ` Aldy Hernandez
2023-03-29 9:39 ` Aldy Hernandez
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=f58bf13e-6e3a-1838-90ae-13e5e005f6ec@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
/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).