Przeglądaj źródła

* Using x86-specific capability of shifting with carry flag helps to reduce amount of instructions.

git-svn-id: trunk@27899 -
sergei 11 lat temu
rodzic
commit
ed46a07f62
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3 2
      compiler/i386/n386mat.pas

+ 3 - 2
compiler/i386/n386mat.pas

@@ -184,9 +184,10 @@ implementation
                         cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_EAX);
                         if m_add then
                           begin
-                            emit_reg_reg(A_SUB,S_L,NR_EDX,hreg1);
-                            emit_const_reg(A_SHR,S_L,1,hreg1);
+                            { addition can overflow, shift first bit considering carry,
+                              then shift remaining bits in regular way. }
                             emit_reg_reg(A_ADD,S_L,hreg1,NR_EDX);
+                            emit_const_reg(A_RCR,S_L,1,NR_EDX);
                             dec(s);
                           end;
                         if s<>0 then