Browse Source

* load 64 bit constants through a register into memory to avoid store-forwarding stalls, resolves #40945

florian 9 months ago
parent
commit
210cb8cb74
1 changed files with 4 additions and 3 deletions
  1. 4 3
      compiler/x86/cgx86.pas

+ 4 - 3
compiler/x86/cgx86.pas

@@ -955,6 +955,7 @@ unit cgx86;
     procedure tcgx86.a_load_const_ref(list : TAsmList; tosize: tcgsize; a : tcgint;const ref : treference);
     procedure tcgx86.a_load_const_ref(list : TAsmList; tosize: tcgsize; a : tcgint;const ref : treference);
       var
       var
         tmpref : treference;
         tmpref : treference;
+        tmpreg: TRegister;
       begin
       begin
         tmpref:=ref;
         tmpref:=ref;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
@@ -963,9 +964,9 @@ unit cgx86;
         if (tosize in [OS_S64,OS_64]) and
         if (tosize in [OS_S64,OS_64]) and
            ((a<low(longint)) or (a>high(longint))) then
            ((a<low(longint)) or (a>high(longint))) then
           begin
           begin
-            a_load_const_ref(list,OS_32,longint(a and $ffffffff),tmpref);
-            inc(tmpref.offset,4);
-            a_load_const_ref(list,OS_32,longint(a shr 32),tmpref);
+            tmpreg:=getintregister(list,tosize);
+            a_load_const_reg(list,tosize,a,tmpreg);
+            a_load_reg_ref(list,tosize,tosize,tmpreg,tmpref);
           end
           end
         else
         else
 {$endif x86_64}
 {$endif x86_64}