From 420f7af21327ef318263fdadee8a9738f37c5354 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 5 May 2025 22:46:49 +0200 Subject: [PATCH] * when handling spilling of mm registers of (v)movd/(v)movq consider also the destination operand (cherry picked from commit 0632cb548a40409e884a0e424c295ac4cc2790f5) --- compiler/x86/rgx86.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/x86/rgx86.pas b/compiler/x86/rgx86.pas index 3f68a0bd9e..36df0f84d7 100644 --- a/compiler/x86/rgx86.pas +++ b/compiler/x86/rgx86.pas @@ -399,18 +399,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;