]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Rename Is_Infinity to Is_Infinity_Or_NaN in System.Double_Real
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 27 Feb 2025 11:09:03 +0000 (12:09 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:02 +0000 (08:32 +0200)
The predicate is used to detect corner cases in multiplicative operations
and also returns True for NaNs.

gcc/ada/ChangeLog:

* libgnat/s-dourea.adb (Is_Infinity): Rename to...
(Is_Infinity_Or_NaN): ...this.
("*"): Adjust accordingly.
("/"): Likewise.
(Sqr): Likewise.
* libgnat/s-dorepr.adb (Two_Prod): Likewise.
(Two_Sqr): Likewise.
* libgnat/s-dorepr__fma.adb (Two_Prod): Likewise.

gcc/ada/libgnat/s-dorepr.adb
gcc/ada/libgnat/s-dorepr__fma.adb
gcc/ada/libgnat/s-dourea.adb

index ddc7c1dad17e9cd8eb101a9e9e29a351eeebebba..1d9604aa1fda4761a7712380e515ea610d85949c 100644 (file)
@@ -134,7 +134,7 @@ package body Product is
       Ahi, Alo, Bhi, Blo, E : Num;
 
    begin
-      if Is_Infinity (P) or else Is_Zero (P) then
+      if Is_Infinity_Or_NaN (P) or else Is_Zero (P) then
          return (P, 0.0);
 
       else
@@ -157,7 +157,7 @@ package body Product is
       Hi, Lo, E : Num;
 
    begin
-      if Is_Infinity (Q) or else Is_Zero (Q) then
+      if Is_Infinity_Or_NaN (Q) or else Is_Zero (Q) then
          return (Q, 0.0);
 
       else
index 0d3dc5382447878c470888d9ed5964e3e5763723..45a92238e829b5ef00263c1b6a0d690170b1c63a 100644 (file)
@@ -78,7 +78,7 @@ package body Product is
       E : Num;
 
    begin
-      if Is_Infinity (P) or else Is_Zero (P) then
+      if Is_Infinity_Or_NaN (P) or else Is_Zero (P) then
          return (P, 0.0);
 
       else
index a37f2eb03c3fc8e46d706b3cc77c7c42359e0f1a..68d4d9a02d886067530adba3c9f9cb2fd1f79e14 100644 (file)
@@ -34,12 +34,12 @@ package body System.Double_Real is
    function Is_NaN (N : Num) return Boolean is (N /= N);
    --  Return True if N is a NaN
 
-   function Is_Infinity (N : Num) return Boolean is (Is_NaN (N - N));
-   --  Return True if N is an infinity. Used to avoid propagating meaningless
-   --  errors when the result of a product is an infinity.
+   function Is_Infinity_Or_NaN (N : Num) return Boolean is (Is_NaN (N - N));
+   --  Return True if N is either an infinity or NaN. Used to avoid propagating
+   --  meaningless errors when the result of a product is an infinity or NaN.
 
    function Is_Zero (N : Num) return Boolean is (N = -N);
-   --  Return True if N is a Zero. Used to preserve the sign when the result of
+   --  Return True if N is a zero. Used to preserve the sign when the result of
    --  a product is a zero.
 
    package Product is
@@ -151,7 +151,7 @@ package body System.Double_Real is
       P : constant Double_T := Two_Prod (A.Hi, B);
 
    begin
-      if Is_Infinity (P.Hi) or else Is_Zero (P.Hi) then
+      if Is_Infinity_Or_NaN (P.Hi) or else Is_Zero (P.Hi) then
          return (P.Hi, 0.0);
       else
          return Quick_Two_Sum (P.Hi, P.Lo + A.Lo * B);
@@ -162,7 +162,7 @@ package body System.Double_Real is
       P : constant Double_T := Two_Prod (A.Hi, B.Hi);
 
    begin
-      if Is_Infinity (P.Hi) or else Is_Zero (P.Hi) then
+      if Is_Infinity_Or_NaN (P.Hi) or else Is_Zero (P.Hi) then
          return (P.Hi, 0.0);
       else
          return Quick_Two_Sum (P.Hi, P.Lo + A.Hi * B.Lo + A.Lo * B.Hi);
@@ -178,7 +178,7 @@ package body System.Double_Real is
       P, R   : Double_T;
 
    begin
-      if Is_Infinity (B) or else Is_Zero (B) then
+      if Is_Infinity_Or_NaN (B) or else Is_Zero (B) then
          return (A.Hi / B, 0.0);
       end if;
       pragma Annotate (CodePeer, Intentional, "test always false",
@@ -202,7 +202,7 @@ package body System.Double_Real is
       R, S       : Double_T;
 
    begin
-      if Is_Infinity (B.Hi) or else Is_Zero (B.Hi) then
+      if Is_Infinity_Or_NaN (B.Hi) or else Is_Zero (B.Hi) then
          return (A.Hi / B.Hi, 0.0);
       end if;
       pragma Annotate (CodePeer, Intentional, "test always false",
@@ -228,7 +228,7 @@ package body System.Double_Real is
       Q : constant Double_T := Two_Sqr (A.Hi);
 
    begin
-      if Is_Infinity (Q.Hi) or else Is_Zero (Q.Hi) then
+      if Is_Infinity_Or_NaN (Q.Hi) or else Is_Zero (Q.Hi) then
          return (Q.Hi, 0.0);
       else
          return Quick_Two_Sum (Q.Hi, Q.Lo + 2.0 * A.Hi * A.Lo + A.Lo * A.Lo);