aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-01-15 19:01:59 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-06 03:51:26 -0400
commit799dfd944ab88e1a32e537fcef7307634c376907 (patch)
tree2b9fb3168573c887e61f40b3e9a2387a135b26ad /gcc/ada
parentaf9833a10a6b8f98147ced304c39285848cd9f6d (diff)
downloadgcc-799dfd944ab88e1a32e537fcef7307634c376907.zip
gcc-799dfd944ab88e1a32e537fcef7307634c376907.tar.gz
gcc-799dfd944ab88e1a32e537fcef7307634c376907.tar.bz2
[Ada] Make new implementation of System.Fat_Gen.Valid more robust
gcc/ada/ * libgnat/s-fatgen.adb (Valid): Do a bit comparison with 0.0 when denormalized numbers are not supported.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/libgnat/s-fatgen.adb14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb
index 6e9ef98..95c0549 100644
--- a/gcc/ada/libgnat/s-fatgen.adb
+++ b/gcc/ada/libgnat/s-fatgen.adb
@@ -959,7 +959,19 @@ package body System.Fat_Gen is
else pragma Assert (Exp = IEEE_Emin - 1);
-- This is a denormalized number, valid if T'Denorm is True or 0.0
- return T'Denorm or else X.all = 0.0;
+ if T'Denorm then
+ return True;
+
+ -- Note that we cannot do a direct comparison with 0.0 because the
+ -- hardware may evaluate it to True for all denormalized numbers.
+
+ else
+ -- First clear the sign bit (the exponent is already zero)
+
+ Rep (MSW) := Rep (MSW) and not Sign_Mask;
+
+ return (for all J in 0 .. Rep_Last => Rep (J) = 0);
+ end if;
end if;
end Valid;