From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] [ranger] x == -0.0 does not mean we can replace x with -0.0
Date: Mon, 29 Aug 2022 08:20:44 -0600 [thread overview]
Message-ID: <616b4af5-e3b7-844e-5dcf-a73a5280d114@gmail.com> (raw)
In-Reply-To: <CAGm3qMXaqaBf_2CoK3ROOjdJrk5i+kPSME8rUKGo5WWZKnikVQ@mail.gmail.com>
On 8/29/2022 7:31 AM, Aldy Hernandez via Gcc-patches wrote:
> On Mon, Aug 29, 2022 at 3:22 PM Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Aug 29, 2022 at 03:13:21PM +0200, Aldy Hernandez wrote:
>>> It seems to me we can do this optimization regardless, but then treat
>>> positive and negative zero the same throughout the frange class.
>>> Particularly, in frange::singleton_p(). We should never return TRUE
>>> for any version of 0.0. This will keep VRP from propagating an
>>> incorrect 0.0, since all VRP does is propagate when a range is
>>> provably a singleton. Also, frange::zero_p() shall return true for
>>> any version of 0.0.
>> Well, I think for HONOR_SIGNED_ZEROS it would be nice if frange was able to
>> differentiate between 0.0 and -0.0.
>> One reason is e.g. to be able to optimize copysign/signbit - if we can
>> prove that the sign bit on some value will be always cleared or always set,
>> we can fold those.
>> On the other side, with -fno-signed-zeros it is invalid to use
>> copysign/signbit on values that could be zero (well, nothing guarantees
>> whether the sign bit is set or clear), so for MODE_HAS_SIGNED_ZEROS &&
>> !HONOR_SIGNED_ZEROS it is best to treat contains_p as {-0.0,0.0} being
>> one thing (just not singleton_p) and not bother with details like whether
>> a range ends or starts with -0.0 or 0.0, either of them would work the same.
>> And for !MODE_HAS_SIGNED_ZEROS, obviously 0.0 can be singleton_p.
> *head explodes*
>
> Ok, I think I can add a zero property we can track (like we do for
> NAN), and set it appropriately at constant creation and upon results
> from copysign/signbit. However, I am running out of time before
> Cauldron, so I think I'll just treat +-0.0 ambiguously for now, and do
> that as a follow-up.
We definitely want to be able to track +-0.0 and distinguish between
them. IIRC there's cases where you can start eliminating comparisons
and arithmetic once you start tracking -0.0 state.
Jeff
next prev parent reply other threads:[~2022-08-29 14:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 15:46 Aldy Hernandez
2022-08-26 16:40 ` Jakub Jelinek
2022-08-29 13:13 ` Aldy Hernandez
2022-08-29 13:21 ` Jakub Jelinek
2022-08-29 13:31 ` Aldy Hernandez
2022-08-29 14:20 ` Jeff Law [this message]
2022-08-29 14:26 ` Aldy Hernandez
2022-08-29 15:08 ` Jeff Law
2022-08-29 15:13 ` Toon Moene
2022-08-29 17:07 ` Jeff Law
2022-08-29 17:37 ` Koning, Paul
2022-08-29 19:04 ` Toon Moene
2022-08-29 15:29 ` Aldy Hernandez
2022-08-31 10:08 ` 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=616b4af5-e3b7-844e-5dcf-a73a5280d114@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/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).