[Ada] Do not second-guess the hardware for underflow handling of Scaling

Message ID 20210506075812.GA125683@adacore.com
State New
Headers show
Series
  • [Ada] Do not second-guess the hardware for underflow handling of Scaling
Related show

Commit Message

Pierre-Marie de Rodat May 6, 2021, 7:58 a.m.
This defers to the hardware implementation for the handling of underflow
in the Scaling routine also in the case where denormals are not supported.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-fatgen.adb (Scaling): Use single handling of
	underflow.  Add pragma Annotate.

Patch

diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb
--- a/gcc/ada/libgnat/s-fatgen.adb
+++ b/gcc/ada/libgnat/s-fatgen.adb
@@ -781,11 +781,9 @@  package body System.Fat_Gen is
          --  Check for underflow
 
          elsif Adjustment < IEEE_Emin - Exp then
-            --  Check for gradual underflow
+            --  Check for possibly gradual underflow (up to the hardware)
 
-            if T'Denorm
-              and then Adjustment >= IEEE_Emin - Mantissa - Exp
-            then
+            if Adjustment >= IEEE_Emin - Mantissa - Exp then
                Expf := IEEE_Emin;
                Expi := Exp + Adjustment - Expf;
 
@@ -810,6 +808,9 @@  package body System.Fat_Gen is
             --  Given that Expi >= -Mantissa, only -64 is problematic
 
             if Expi = -64 then
+               pragma Annotate
+                 (CodePeer, Intentional, "test always false",
+                  "test always false in some instantiations");
                XX := XX / 2.0;
                Expi := -63;
             end if;