public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED 1/4] Fix floating point bug in fold_range.
@ 2023-06-08 18:57 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2023-06-08 18:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: hernandez, aldy

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

We currently do not have any floating point operators where operand 1 is 
a different type than the LHS. When we eventually do there is a bug in 
fold_range. If either operand is a known NAN, it returns a NAN of the 
type of operand 1 instead of the result type.

This patch sets it to the correct type.

Bootstraps on build-x86_64-pc-linux-gnu with no regressions. Pushed.

Andrew


[-- Attachment #2: 0001-Fix-floating-point-bug-in-fold_range.patch --]
[-- Type: text/x-patch, Size: 1042 bytes --]

From ff0ef34aa04f7767933541f58f016600a3462c84 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Wed, 7 Jun 2023 14:03:35 -0400
Subject: [PATCH 1/4] Fix floating point bug in fold_range.

We currently do not have any floating point operators where operand 1 is
a different type than the LHS. When we eventually do there is a bug
in fold_range. If either operand is a known NAN, it returns a NAN
of the type of operand 1 instead of the result type.

	* range-op-float.cc (range_operator_float::fold_range): Return
	NAN of the result type.
---
 gcc/range-op-float.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index a99a6b01ed8..af598b60a79 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -57,7 +57,7 @@ range_operator_float::fold_range (frange &r, tree type,
     return true;
   if (op1.known_isnan () || op2.known_isnan ())
     {
-      r.set_nan (op1.type ());
+      r.set_nan (type);
       return true;
     }
 
-- 
2.40.1


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

only message in thread, other threads:[~2023-06-08 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-08 18:57 [COMMITTED 1/4] Fix floating point bug in fold_range Andrew MacLeod

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).