Browse Source

* more aggressive cse on thread vars

florian 3 months ago
parent
commit
84a852bc13
1 changed files with 8 additions and 1 deletions
  1. 8 1
      compiler/optcse.pas

+ 8 - 1
compiler/optcse.pas

@@ -48,6 +48,7 @@ unit optcse;
 
     uses
       globtype,globals,
+      systems,
       cutils,cclasses,
       nutils,compinnr,
       nbas,nld,ninl,ncal,nadd,nmem,ncnv,
@@ -645,7 +646,13 @@ unit optcse;
                   end;
               end;
             if found then
-              inc(consts^[i].weight)
+              begin
+                inc(consts^[i].weight);
+
+                { non-sectioned threadvars really hurt so do more aggressive cse on them }
+                if not(tf_section_threadvars in target_info.flags) and (n.nodetype=loadn) and (tloadnode(n).symtableentry.typ=staticvarsym) and (vo_is_thread_var in tstaticvarsym(tloadnode(n).symtableentry).varoptions) then
+                  inc(consts^[i].weight);
+              end
             else
               begin
                 SetLength(consts^,length(consts^)+1);