瀏覽代碼

* Reverted r29373 and replaced it with more appropriate fix.

git-svn-id: trunk@33093 -
sergei 9 年之前
父節點
當前提交
e8f2f42b75
共有 1 個文件被更改,包括 8 次插入9 次删除
  1. 8 9
      compiler/mips/aoptcpu.pas

+ 8 - 9
compiler/mips/aoptcpu.pas

@@ -271,17 +271,18 @@ unit aoptcpu;
             begin
             begin
               { try to optimize the typical call sequence
               { try to optimize the typical call sequence
                 lw  $reg, (whatever)
                 lw  $reg, (whatever)
-                <alloc volatile registers>
+                <alloc volatile registers (including $reg!!)>
                 move $t9,$reg
                 move $t9,$reg
                 jalr $t9
                 jalr $t9
-                Do not do so if the used register might contain a 
-                register variable.      }
+
+                if $reg is nonvolatile, its value may be used after call 
+                and we cannot safely replace it with $t9 }
               if (opcode=A_MOVE) and
               if (opcode=A_MOVE) and
-                 not(cs_opt_regvar in current_settings.optimizerswitches) and
                  (taicpu(next).oper[0]^.reg=NR_R25) and
                  (taicpu(next).oper[0]^.reg=NR_R25) and
                  GetNextInstruction(next,hp1) and
                  GetNextInstruction(next,hp1) and
                  MatchInstruction(hp1,A_JALR) and
                  MatchInstruction(hp1,A_JALR) and
-                 MatchOperand(taicpu(hp1).oper[0]^,NR_R25) then
+                 MatchOperand(taicpu(hp1).oper[0]^,NR_R25) and
+                 assigned(FindRegAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) then
                 begin
                 begin
                   taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
                   taicpu(p).loadreg(0,taicpu(next).oper[0]^.reg);
                   asml.remove(next);
                   asml.remove(next);
@@ -499,8 +500,7 @@ unit aoptcpu;
                       else if (taicpu(next).opcode in [A_ADD,A_ADDU,A_ADDI,A_ADDIU,A_SUB,A_SUBU]) and
                       else if (taicpu(next).opcode in [A_ADD,A_ADDU,A_ADDI,A_ADDIU,A_SUB,A_SUBU]) and
                          MatchOperand(taicpu(next).oper[0]^,taicpu(p).oper[0]^.reg) then
                          MatchOperand(taicpu(next).oper[0]^,taicpu(p).oper[0]^.reg) then
                         begin
                         begin
-                          if MatchOperand(taicpu(next).oper[1]^,taicpu(p).oper[0]^.reg) and
-                             Assigned(FindRegDealloc(taicpu(p).oper[0]^.reg,tai(next.next))) then
+                          if MatchOperand(taicpu(next).oper[1]^,taicpu(p).oper[0]^.reg) then
                             begin
                             begin
                               taicpu(next).loadreg(1,taicpu(p).oper[1]^.reg);
                               taicpu(next).loadreg(1,taicpu(p).oper[1]^.reg);
                               asml.remove(p);
                               asml.remove(p);
@@ -509,8 +509,7 @@ unit aoptcpu;
                             end
                             end
                           { TODO: if Ry=NR_R0, this effectively changes instruction into MOVE,
                           { TODO: if Ry=NR_R0, this effectively changes instruction into MOVE,
                             providing further optimization possibilities }
                             providing further optimization possibilities }
-                          else if MatchOperand(taicpu(next).oper[2]^,taicpu(p).oper[0]^.reg) and
-                                  Assigned(FindRegDealloc(taicpu(p).oper[0]^.reg,tai(next.next))) then
+                          else if MatchOperand(taicpu(next).oper[2]^,taicpu(p).oper[0]^.reg) then
                             begin
                             begin
                               taicpu(next).loadreg(2,taicpu(p).oper[1]^.reg);
                               taicpu(next).loadreg(2,taicpu(p).oper[1]^.reg);
                               asml.remove(p);
                               asml.remove(p);