Selaa lähdekoodia

+ better precision in determining the registers, read by mul/imul/div/idiv in
i386's TCpuAsmOptimizer.RegReadByInstruction:
* mul doesn't read edx (unless included in operand)
* 8-bit mul and imul don't read ah (unless included in operand)
* 8-bit div and idiv don't read edx (unless included in operand)

git-svn-id: trunk@35958 -

nickysn 8 vuotta sitten
vanhempi
commit
0f010430cc
1 muutettua tiedostoa jossa 21 lisäystä ja 5 poistoa
  1. 21 5
      compiler/i386/aoptcpu.pas

+ 21 - 5
compiler/i386/aoptcpu.pas

@@ -160,17 +160,33 @@ unit aoptcpu;
         A_IMUL:
           case p.ops of
             1:
-              regReadByInstruction :=
-                 (reg = NR_EAX) or RegInOp(reg,p.oper[0]^);
+              regReadByInstruction := RegInOp(reg,p.oper[0]^) or
+                 (
+                  ((getregtype(reg)=R_INTREGISTER) and (getsupreg(reg)=RS_EAX)) and
+                  ((getsubreg(reg)<>R_SUBH) or (p.opsize<>S_B))
+                 );
             2,3:
               regReadByInstruction :=
                 reginop(reg,p.oper[0]^) or
                 reginop(reg,p.oper[1]^);
           end;
-        A_IDIV,A_DIV,A_MUL:
+        A_MUL:
+          begin
+            regReadByInstruction := RegInOp(reg,p.oper[0]^) or
+               (
+                ((getregtype(reg)=R_INTREGISTER) and (getsupreg(reg)=RS_EAX)) and
+                ((getsubreg(reg)<>R_SUBH) or (p.opsize<>S_B))
+               );
+          end;
+        A_IDIV,A_DIV:
           begin
-            regReadByInstruction :=
-              RegInOp(reg,p.oper[0]^) or ((getregtype(reg)=R_INTREGISTER) and (getsupreg(reg) in [RS_EAX,RS_EDX]));
+            regReadByInstruction := RegInOp(reg,p.oper[0]^) or
+               (
+                 (getregtype(reg)=R_INTREGISTER) and
+                 (
+                   (getsupreg(reg)=RS_EAX) or ((getsupreg(reg)=RS_EDX) and (p.opsize<>S_B))
+                 )
+               );
           end;
         else
           begin