aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.cc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-09-12 13:04:02 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-09-12 15:08:38 +0200
commit06b30eecdd9822842a0ff21548ab92f01adb2795 (patch)
tree185106e1413cf61cc10e97bb1a793fca12599915 /gcc/value-range.cc
parent71cd6a0430ca2a2c44e3cf4cc9f3c96d3aef1ab7 (diff)
downloadgcc-06b30eecdd9822842a0ff21548ab92f01adb2795.zip
gcc-06b30eecdd9822842a0ff21548ab92f01adb2795.tar.gz
gcc-06b30eecdd9822842a0ff21548ab92f01adb2795.tar.bz2
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.
Diffstat (limited to 'gcc/value-range.cc')
-rw-r--r--gcc/value-range.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index adcaaa2..6f06099 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.