* [COMMITTED] frange::set_signbit: Avoid changing sign when already in the correct sign.
@ 2022-09-12 13:07 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-09-12 13:07 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
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.
---
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.
--
2.37.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-12 13:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 13:07 [COMMITTED] frange::set_signbit: Avoid changing sign when already in the correct sign Aldy Hernandez
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).