From e09304f67163e4419ecee27440712da5e09e8451 Mon Sep 17 00:00:00 2001 From: Karoly Balogh Date: Mon, 17 Feb 2025 11:50:20 +0100 Subject: [PATCH] m68k: do not try to optimize CMP #0,Ax to TST Ax, if the CPU doesn't support it --- compiler/m68k/aoptcpu.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/m68k/aoptcpu.pas b/compiler/m68k/aoptcpu.pas index 8245985098..12b0dda88e 100644 --- a/compiler/m68k/aoptcpu.pas +++ b/compiler/m68k/aoptcpu.pas @@ -570,8 +570,12 @@ unit aoptcpu; end; { CMP #0, equals to TST , just shorter and TST is more flexible anyway } A_CMP,A_CMPI: - if (taicpu(p).oper[0]^.typ = top_const) and - (taicpu(p).oper[0]^.val = 0) then + if ((taicpu(p).oper[0]^.typ = top_const) and + (taicpu(p).oper[0]^.val = 0)) and + ((taicpu(p).oper[1]^.typ = top_ref) or + ((taicpu(p).oper[1]^.typ = top_reg) and + not (isaddressregister(taicpu(p).oper[1]^.reg) and + not (CPUM68K_HAS_TSTAREG in cpu_capabilities[current_settings.cputype])))) then begin DebugMsg('Optimizer: CMP #0 to TST',p); taicpu(p).opcode:=A_TST;