Browse Source

* Fixed a register allocator bug
* Figured out why -dnewra generates superfluous "mov reg1,reg2"
statements: changes in location_force. These moves are now no longer
constrained so they are optimized away.

daniel 22 years ago
parent
commit
557ac8b02e
2 changed files with 23 additions and 3 deletions
  1. 11 1
      compiler/ncgutil.pas
  2. 12 2
      compiler/rgobj.pas

+ 11 - 1
compiler/ncgutil.pas

@@ -427,6 +427,8 @@ implementation
                rg.ungetregisterint(list,l.registerhigh);
                l.registerhigh.enum:=R_NO;
              end;
+            if l.loc=LOC_REGISTER then
+              rg.ungetregisterint(list,l.register);
            {Do not bother to recycle the existing register. The register
             allocator eliminates unnecessary moves, so it's not needed
             and trying to recycle registers can cause problems because
@@ -513,6 +515,7 @@ implementation
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                    l.size:=dst_size;
 {$endif not i386}
+{$ifndef newra}
                  { Release old register when the superregister is changed }
                  if (l.loc=LOC_REGISTER) and
                     (l.register.number shr 8<>hregister.number shr 8) then
@@ -522,6 +525,7 @@ implementation
                      else
                        rg.ungetregisterint(list,l.register);
                    end;
+{$endif}
                end;
            end;
            if (l.loc <> LOC_CREGISTER) or
@@ -2026,7 +2030,13 @@ implementation
 end.
 {
   $Log$
-  Revision 1.131  2003-07-23 11:04:15  jonas
+  Revision 1.132  2003-08-03 14:09:50  daniel
+    * Fixed a register allocator bug
+    * Figured out why -dnewra generates superfluous "mov reg1,reg2"
+      statements: changes in location_force. These moves are now no longer
+      constrained so they are optimized away.
+
+  Revision 1.131  2003/07/23 11:04:15  jonas
     * split en_exit_code into a part that may allocate a register and a part
       that doesn't, so the former can be done before the register colouring
       has been performed

+ 12 - 2
compiler/rgobj.pas

@@ -1861,8 +1861,12 @@ unit rgobj;
             t:=adj^[i];
             if (pos(t,selectstack) or pos(t,coalescednodes))=0 then
               begin
-                decrement_degree(Tsuperregister(t));
                 add_edge(Tsuperregister(t),u);
+                {Do not call decrement_degree because it might move nodes between
+                 lists while the degree does not change (add_edge will increase it).
+                 Instead, we will decrement manually.}
+                if degree[Tsuperregister(t)]>0 then
+                  dec(degree[Tsuperregister(t)]);
               end;
           end;
       p:=pos(char(u),freezeworklist);
@@ -2538,7 +2542,13 @@ end.
 
 {
   $Log$
-  Revision 1.61  2003-07-21 13:32:39  jonas
+  Revision 1.62  2003-08-03 14:09:50  daniel
+    * Fixed a register allocator bug
+    * Figured out why -dnewra generates superfluous "mov reg1,reg2"
+      statements: changes in location_force. These moves are now no longer
+      constrained so they are optimized away.
+
+  Revision 1.61  2003/07/21 13:32:39  jonas
     * add_edges_used() is now also called for registers allocated with
       getexplicitregisterint()
     * writing the intereference graph is now only done with -dradebug2 and