Browse Source

* x86: Corrected placement of ECX deallocation for shift/rotate instructions

J. Gareth "Curious Kit" Moreton 3 months ago
parent
commit
2e6d9cc2ec
1 changed files with 8 additions and 2 deletions
  1. 8 2
      compiler/x86/cgx86.pas

+ 8 - 2
compiler/x86/cgx86.pas

@@ -2351,8 +2351,11 @@ unit cgx86;
               { Use ecx to load the value, that allows better coalescing }
               getcpuregister(list,REGCX);
               a_load_reg_reg(list,reg_cgsize(src),REGCX_Size,src,REGCX);
-              list.concat(taicpu.op_reg_reg(Topcg2asmop[op],tcgsize2opsize[size],NR_CL,dst));
+              { Deallocate right before the instruction - it will be corrected
+                later by the register allocator (not correcting it will cause
+                it to be deallocated one instruction too late) }
               ungetcpuregister(list,REGCX);
+              list.concat(taicpu.op_reg_reg(Topcg2asmop[op],tcgsize2opsize[size],NR_CL,dst));
             end;
           else
             begin
@@ -2443,8 +2446,11 @@ unit cgx86;
               { Use ecx to load the value, that allows better coalescing }
               getcpuregister(list,REGCX);
               a_load_reg_reg(list,reg_cgsize(reg),REGCX_Size,reg,REGCX);
-              list.concat(taicpu.op_reg_ref(TOpCG2AsmOp[op],tcgsize2opsize[size],NR_CL,tmpref));
+              { Deallocate right before the instruction - it will be corrected
+                later by the register allocator (not correcting it will cause
+                it to be deallocated one instruction too late) }
               ungetcpuregister(list,REGCX);
+              list.concat(taicpu.op_reg_ref(TOpCG2AsmOp[op],tcgsize2opsize[size],NR_CL,tmpref));
             end;
           OP_IMUL:
             begin