From: Eric Botcazou <ebotca...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-dorepr.adb | 4 ++-- gcc/ada/libgnat/s-dorepr__fma.adb | 2 +- gcc/ada/libgnat/s-dourea.adb | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/ada/libgnat/s-dorepr.adb b/gcc/ada/libgnat/s-dorepr.adb index ddc7c1dad17..1d9604aa1fd 100644 --- a/gcc/ada/libgnat/s-dorepr.adb +++ b/gcc/ada/libgnat/s-dorepr.adb @@ -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 diff --git a/gcc/ada/libgnat/s-dorepr__fma.adb b/gcc/ada/libgnat/s-dorepr__fma.adb index 0d3dc538244..45a92238e82 100644 --- a/gcc/ada/libgnat/s-dorepr__fma.adb +++ b/gcc/ada/libgnat/s-dorepr__fma.adb @@ -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 diff --git a/gcc/ada/libgnat/s-dourea.adb b/gcc/ada/libgnat/s-dourea.adb index a37f2eb03c3..68d4d9a02d8 100644 --- a/gcc/ada/libgnat/s-dourea.adb +++ b/gcc/ada/libgnat/s-dourea.adb @@ -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); -- 2.43.0