public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2624] frange::set_signbit: Avoid changing sign when already in the correct sign. Date: Mon, 12 Sep 2022 13:08:48 +0000 (GMT) [thread overview] Message-ID: <20220912130848.36DC9385AC34@sourceware.org> (raw) https://gcc.gnu.org/g:06b30eecdd9822842a0ff21548ab92f01adb2795 commit r13-2624-g06b30eecdd9822842a0ff21548ab92f01adb2795 Author: Aldy Hernandez <aldyh@redhat.com> Date: Mon Sep 12 13:04:02 2022 +0200 frange::set_signbit: Avoid changing sign when already in the correct sign. We should avoid pessimizing the signbit when it's already correct. In this particular case we were trying to change the signbit to "unknown", when it was obviously negative. This test is actually slated for removal with my upcoming revamp of the signbit and NAN tracking, per the conversations regarding tristate. The signbit will be removed in favor of keeping track of it in the range itself, and NAN will just be a pair of boolean flags. However, I don't plan to disturb the tree until after Cauldron. Tested on x86-64 Linux including mpfr tests. Also tested selftests with -ffinite-math-only on x86-64 as well as on a cross to pdp11-aout. gcc/ChangeLog: * value-range.cc (frange::set_signbit): Avoid changing sign when already in the correct sign. Diff: --- gcc/value-range.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index adcaaa2a69a..6f0609959b3 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -316,9 +316,13 @@ frange::set_signbit (fp_prop::kind k) // Ignore sign changes when they're set correctly. if (!maybe_nan ()) { - if (real_less (&m_max, &dconst0)) + // It's negative and we're trying to make it negative or varying. + if (real_less (&m_max, &dconst0) && (k == fp_prop::YES + || k == fp_prop::VARYING)) return; - if (real_less (&dconst0, &m_min)) + // It's positive and we're trying to make it positive or varying. + if (real_less (&dconst0, &m_min) && (k == fp_prop::NO + || k == fp_prop::VARYING)) return; } // Adjust the range depending on the sign bit.
reply other threads:[~2022-09-12 13:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220912130848.36DC9385AC34@sourceware.org \ --to=aldyh@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).