]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not fold __builtin_signbit if NAN is a possibility.
authorAldy Hernandez <aldyh@redhat.com>
Mon, 5 Sep 2022 18:06:30 +0000 (20:06 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 5 Sep 2022 20:16:14 +0000 (22:16 +0200)
I had some queued up work to try harder to keep the sign bit up to
date in the presence of NANs, but after the discussion with Richi
regarding the representation of NAN and signs in the frange, I've
decided to put it aside until after Cauldron, since it'll probably get
rewritten anyhow.  So for now, the sign property in the frange is not
applicable to NANs.

Right now the only user of the sign bit that affects generated code
(apart from signed zeros) is __builtin_sign, so I'm just checking for
NAN there.  Signed zeros continue working as before.

Regstrapped and mpfr checked on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-fold.cc
(fold_using_range::range_of_builtin_int_call): Ignore sign bit
when there's the possibility of a NAN.

gcc/gimple-range-fold.cc

index 3543f0980b818cf1df3b648aa3916b95c873bd6f..c9c7a2ccc7026e40b4292bbdebff812d9ac60d29 100644 (file)
@@ -1029,7 +1029,9 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call,
        frange tmp;
        if (src.get_operand (tmp, arg))
          {
-           if (tmp.get_signbit ().varying_p ())
+           if (tmp.get_signbit ().varying_p ()
+               // FIXME: We don't support signed NANs yet.
+               || !tmp.get_nan ().no_p ())
              return false;
            if (tmp.get_signbit ().yes_p ())
              r.set_nonzero (type);