Explorar o código

Avoid float_raise call in FPC_SOFT_FPUX80 code

(cherry picked from commit 5cedecbe25d5a2493e54cd01bf7cf13499a99065)
Pierre Muller %!s(int64=2) %!d(string=hai) anos
pai
achega
59ad47503b
Modificáronse 1 ficheiros con 43 adicións e 9 borrados
  1. 43 9
      compiler/assemble.pas

+ 43 - 9
compiler/assemble.pas

@@ -1054,6 +1054,8 @@ Implementation
         eextended: extended;
 {$else}
 {$ifdef FPC_SOFT_FPUX80}
+	f32 : float32;
+	f64 : float64;
 	eextended: floatx80;
 {$endif}
 {$endif cpuextended}
@@ -1118,9 +1120,24 @@ Implementation
           aitrealconst_s80bit:
             begin
 	      if sizeof(tai_realconst(hp).value.s80val) = sizeof(double) then
-                eextended:=float64_to_floatx80(float64(double(tai_realconst(hp).value.s80val)))
+                begin
+                  f64:=float64(double(tai_realconst(hp).value.s80val));
+                  if float64_is_signaling_nan(f64)<>0 then
+                    begin
+                      f64.low := 0;
+                      f64.high := longword($fff80000);
+                    end;
+                  eextended:=float64_to_floatx80(f64);
+                end
 	      else if sizeof(tai_realconst(hp).value.s80val) = sizeof(single) then
-	        eextended:=float32_to_floatx80(float32(single(tai_realconst(hp).value.s80val)))
+                begin
+                  f32:=float32(single(tai_realconst(hp).value.s80val));
+                  if float32_is_signaling_nan(f32)<>0 then
+                    begin
+                      f32 := longword($ffc00000);
+	            end;
+                  eextended:=float32_to_floatx80(f32);
+                end
 	      else
 	        internalerror(2017091901);
               pdata:=@eextended;
@@ -1842,6 +1859,8 @@ Implementation
         eextended : extended;
 	{$else}
         {$ifdef FPC_SOFT_FPUX80}
+	f32 : float32;
+	f64 : float64;
 	eextended : floatx80;
         {$endif}
         {$endif}
@@ -1919,16 +1938,31 @@ Implementation
            {$push}{$warn 6018 off} { Unreachable code due to compile time evaluation }
                    aitrealconst_s80bit:
                      begin
-		       if sizeof(tai_realconst(hp).value.s80val) = sizeof(double) then
-                         eextended:=float64_to_floatx80(float64(double(tai_realconst(hp).value.s80val)))
-		       else if sizeof(tai_realconst(hp).value.s80val) = sizeof(single) then
-			 eextended:=float32_to_floatx80(float32(single(tai_realconst(hp).value.s80val)))
-		       else
-			 internalerror(2017091901);
+                       if sizeof(tai_realconst(hp).value.s80val) = sizeof(double) then
+                         begin
+                           f64:=float64(double(tai_realconst(hp).value.s80val));
+                           if float64_is_signaling_nan(f64)<>0 then
+                             begin
+                               f64.low := 0;
+                               f64.high := longword($fff80000);
+                             end;
+                           eextended:=float64_to_floatx80(f64);
+                         end
+                       else if sizeof(tai_realconst(hp).value.s80val) = sizeof(single) then
+                         begin
+                           f32:=float32(single(tai_realconst(hp).value.s80val));
+                           if float32_is_signaling_nan(f32)<>0 then
+                             begin
+                               f32 := longword($ffc00000);
+                             end;
+                           eextended:=float32_to_floatx80(f32);
+                         end
+                       else
+                         internalerror(2017091903);
                        pdata:=@eextended;
                      end;
            {$pop}
-	 {$endif}
+         {$endif}
          {$endif cpuextended}
                    aitrealconst_s64comp:
                      begin