Optimize out TDC following TCD.

This can occur if the first code in the function (which could be an initializer) takes the address of a local variable.
This commit is contained in:
Stephen Heumann 2022-12-05 18:02:23 -06:00
parent a7d9d3039b
commit 8aedd42294
1 changed files with 8 additions and 1 deletions

View File

@ -1943,6 +1943,13 @@ var
if not volatile then
Remove(ns+1);
m_tcd:
if npeep[ns+1].opcode = m_tdc then
Remove(ns+1)
else if npeep[ns+1].opcode in [m_pea,m_stz_dir,m_stz_abs] then
if npeep[ns+2].opcode = m_tdc then
Remove(ns+2);
otherwise: ;
end; {case}
@ -2511,7 +2518,7 @@ nnextspot := 1;
nleadOpcodes := [m_asl_a,m_bcs,m_beq,m_bmi,m_bne,m_bpl,m_brl,m_bvs,m_bcc,
m_dec_abs,m_lda_abs,m_lda_dir,m_lda_imm,m_ldx_imm,m_sta_abs,m_sta_dir,
m_pha,m_plb,m_plx,m_tax,m_tya,m_tyx,m_phy,m_pei_dir,m_ldy_imm,m_rep,
m_ora_dir,m_ora_abs,m_and_imm,m_pea];
m_ora_dir,m_ora_abs,m_and_imm,m_pea,m_tcd];
nstopOpcodes := [d_end,d_pin];
stringSize := 0; {initialize scalars for a new segment}