Optimize some assembly code sequences that can occur for array access.

Here is an example that benefits from the new optimizations:

#pragma optimize 7
void f(char *a, unsigned i, unsigned n) {
        a[i] = (a[i] & 0xF0) | n;
}
This commit is contained in:
Stephen Heumann 2023-03-09 17:53:45 -06:00
parent 30a04d42c5
commit 7c8ec41148

View File

@ -1781,7 +1781,7 @@ var
end {if} end {if}
end {else if} end {else if}
else if npeep[ns+1].opcode = m_tay then else if npeep[ns+1].opcode = m_tay then
if npeep[ns+2].opcode = m_lda_dir then begin if npeep[ns+2].opcode in [m_lda_dir,m_lda_indly,m_pla] then begin
opcode := m_ldy_dir; opcode := m_ldy_dir;
Remove(ns+1); Remove(ns+1);
end {if} end {if}
@ -1952,7 +1952,8 @@ var
Remove(ns); Remove(ns);
Remove(ns); Remove(ns);
end {if} end {if}
else if npeep[ns+1].opcode in [m_ldx_abs,m_ldx_dir] then else if npeep[ns+1].opcode in
[m_ldx_abs,m_ldx_dir,m_ldy_imm,m_ldy_dir] then
if npeep[ns+2].opcode = m_pla then begin if npeep[ns+2].opcode = m_pla then begin
Remove(ns+2); Remove(ns+2);
Remove(ns); Remove(ns);