Optimize LDA+TAY to LDY (when A is unused after).

This pattern comes up in the new return code when returning a local variable.
This commit is contained in:
Stephen Heumann 2022-12-20 20:21:25 -06:00
parent 854a6779a9
commit cf9f19c93d
1 changed files with 12 additions and 1 deletions

View File

@ -1773,11 +1773,22 @@ var
npeep[ns+2] := npeep[ns];
Remove(ns);
end {else if}
else if npeep[ns+1].opcode = m_xba then
else if npeep[ns+1].opcode = m_xba then begin
if npeep[ns+2].opcode = m_and_imm then
if npeep[ns+2].operand = $00FF then begin
operand := operand+1;
Remove(ns+1);
end {if}
end {else if}
else if npeep[ns+1].opcode = m_tay then
if npeep[ns+2].opcode = m_lda_dir then begin
opcode := m_ldy_dir;
Remove(ns+1);
end {if}
else if npeep[ns+2].opcode = m_pld then
if npeep[ns+3].opcode = m_tsc then begin
opcode := m_ldy_dir;
Remove(ns+1);
end; {if}
m_ldx_dir: