Z80 Incorrect code optimization
I tried the latest Windows x_86_64 (x86_64-w64-mingw32-setup). sdcc --version displays: SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8/f8l TD- 4.5.24 #16514 (MINGW64) published under GNU General Public License (GPL) The exact commands I used to generate the attached .asm files: sdcc -mz80 --no-peep --opt-code-size --max-allocs-per-node 2366 --fverbose-asm ./maxallocs.c and sdcc -mz80...
I tried the latest Windows x_86_64 snapshot (x86_64-w64-mingw32-setup). sdcc --version displays: SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8/f8l TD- 4.5.24 #16514 (MINGW64) published under GNU General Public License (GPL) The exact commands I used to generate the attached .asm files: sdcc -mz80 --no-peep --opt-code-size --max-allocs-per-node 2366 --fverbose-asm ./maxallocs.c and sdcc...
Ok, I managed to create a small snippet of code that demonstrates the issue. If I compile with: sdcc -mz80 --no-peep --opt-code-size --max-allocs-per-node 2366 ./maxallocs.c The code is 'OK', but when compiling with --max-allocs-per-node set to 2367 more space on the stack is reserved for temp variables, resulting in way bigger code. Enabling/disabling the peephole optimizer doesn't have an effect on this issue. I'm not sure about the register content tracking; to me it looks like it should be able...
Z80 optimize assigning same value to multipe variables
Let's say SDCC finds a 'good' but not optimal solution for a specific --max-allocs-per-node value: should a higher --max-allocs-per-node never result in a worse solution? I have a piece of code where --max-allocs-per-node 10484 gives a way better result than with 10485.