public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Do not fold __builtin_signbit if NAN is a possibility.
@ 2022-09-05 20:14 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-09-05 20:14 UTC (permalink / raw)
  To: GCC patches; +Cc: Jakub Jelinek, Andrew MacLeod, Aldy Hernandez

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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 3543f0980b8..c9c7a2ccc70 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -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);
-- 
2.37.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-05 20:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 20:14 [COMMITTED] Do not fold __builtin_signbit if NAN is a possibility 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).