Browse Source

* when handling spilling of mm registers of (v)movd/(v)movq consider also the destination operand

florian 3 months ago
parent
commit
0632cb548a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      compiler/x86/rgx86.pas

+ 5 - 4
compiler/x86/rgx86.pas

@@ -418,18 +418,19 @@ implementation
             { Replace register with spill reference }
             if replaceoper<>-1 then
               begin
-                if replaceoper=0 then
+                if replaceoper<=1 then
                   begin
 {$ifdef x86_64}
                     { if an mm register => int register (v)movq is converted, replace it by MOV with opsize Q }
-                    if ((opcode=A_MOVQ) or (opcode=A_VMOVQ)) and (oper[0]^.typ=top_reg)  and (oper[1]^.typ=top_reg) and (getregtype(oper[1]^.reg)=R_INTREGISTER) then
+                    if ((opcode=A_MOVQ) or (opcode=A_VMOVQ)) and (oper[0]^.typ=top_reg)  and (oper[1]^.typ=top_reg) and (getregtype(oper[replaceoper xor 1]^.reg)=R_INTREGISTER) then
                       begin
                         opcode:=A_MOV;
                         opsize:=S_Q;
-                      end;
+                      end
+                    else
 {$endif x86_64}
                     { if an mm register => int register (v)movd is converted, replace it by MOV with opsize L }
-                    if ((opcode=A_MOVD) or (opcode=A_VMOVD)) and (oper[0]^.typ=top_reg)  and (oper[1]^.typ=top_reg) and (getregtype(oper[1]^.reg)=R_INTREGISTER) then
+                    if ((opcode=A_MOVD) or (opcode=A_VMOVD)) and (oper[0]^.typ=top_reg)  and (oper[1]^.typ=top_reg) and (getregtype(oper[replaceoper xor 1]^.reg)=R_INTREGISTER) then
                       begin
                         opcode:=A_MOV;
                         opsize:=S_L;