From b2ed667a86f9a978c6d2eb6dae48e3f1932a86f8 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 11 Jun 2020 17:19:56 +0000 Subject: [PATCH] * swap fpu stack correctly when moving data into xmm registers git-svn-id: trunk@45637 - --- compiler/x86/nx86add.pas | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/x86/nx86add.pas b/compiler/x86/nx86add.pas index 7e303a93b3..b925c455dd 100644 --- a/compiler/x86/nx86add.pas +++ b/compiler/x86/nx86add.pas @@ -875,14 +875,14 @@ unit nx86add; pass_left_right; { fpu operands are always in reversed order on the stack } - if (left.location.loc=LOC_FPUREGISTER) and (right.location.loc=LOC_FPUREGISTER) then + if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then toggleflag(nf_swapped); if (nf_swapped in flags) then { can't use swapleftright if both are on the fpu stack, since then } { both are "R_ST" -> nothing would change -> manually switch } - if (left.location.loc = LOC_FPUREGISTER) and - (right.location.loc = LOC_FPUREGISTER) then + if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and + (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then emit_none(A_FXCH,S_NO) else swapleftright; @@ -1018,14 +1018,14 @@ unit nx86add; pass_left_right; { fpu operands are always in reversed order on the stack } - if (left.location.loc=LOC_FPUREGISTER) and (right.location.loc=LOC_FPUREGISTER) then + if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then toggleflag(nf_swapped); if (nf_swapped in flags) then { can't use swapleftright if both are on the fpu stack, since then } { both are "R_ST" -> nothing would change -> manually switch } - if (left.location.loc = LOC_FPUREGISTER) and - (right.location.loc = LOC_FPUREGISTER) then + if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and + (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then emit_none(A_FXCH,S_NO) else swapleftright; @@ -1191,6 +1191,10 @@ unit nx86add; internalerror(200402222); pass_left_right; + { fpu operands are always in reversed order on the stack } + if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then + toggleflag(nf_swapped); + location_reset(location,LOC_FLAGS,OS_NO); { Direct move fpu->mm register is not possible, so force any fpu operands to