Browse Source

* also optimize loading of -1.0

florian 1 year ago
parent
commit
aaeefacf85
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/x86/nx86con.pas

+ 9 - 1
compiler/x86/nx86con.pas

@@ -52,7 +52,7 @@ implementation
       begin
       begin
          result:=nil;
          result:=nil;
          if is_number_float(value_real) and not(use_vectorfpu(resultdef)) and ((value_real=1.0) or ((value_real=0.0) and (get_real_sign(value_real)=1)) or
          if is_number_float(value_real) and not(use_vectorfpu(resultdef)) and ((value_real=1.0) or ((value_real=0.0) and (get_real_sign(value_real)=1)) or
-           ((value_real=2.0) and (cs_create_pic in current_settings.moduleswitches))) then
+           (((value_real=2.0) or (value_real=-1.0)) and (cs_create_pic in current_settings.moduleswitches))) then
            expectloc:=LOC_FPUREGISTER
            expectloc:=LOC_FPUREGISTER
          else if (value_real=0.0) and (get_real_sign(value_real)=1) and use_vectorfpu(resultdef) then
          else if (value_real=0.0) and (get_real_sign(value_real)=1) and use_vectorfpu(resultdef) then
            expectloc:=LOC_MMREGISTER
            expectloc:=LOC_MMREGISTER
@@ -80,6 +80,14 @@ implementation
                   location.register:=NR_ST;
                   location.register:=NR_ST;
                   tcgx86(cg).inc_fpu_stack;
                   tcgx86(cg).inc_fpu_stack;
                end
                end
+             else if (value_real=-1.0) and (cs_create_pic in current_settings.moduleswitches) and not(use_vectorfpu(resultdef)) then
+               begin
+                  emit_none(A_FLD1,S_NO);
+                  emit_none(A_FCHS,S_NO);
+                  location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
+                  location.register:=NR_ST;
+                  tcgx86(cg).inc_fpu_stack;
+               end
              else if (value_real=0.0) and (get_real_sign(value_real)=1) then
              else if (value_real=0.0) and (get_real_sign(value_real)=1) then
                begin
                begin
                  if use_vectorfpu(resultdef) then
                  if use_vectorfpu(resultdef) then