Running attached user written peephole opt reducing memory access in the code causes another in-built peephole opt (z80 improved usage of inc) to be triggered breaking later code depending on carry flag. Looking at the in-built peephole opts, another opt (z80 improved usage of dec) may also trigger the same invalid behavior.
The problem can be workarounded by changing the command order in the user peephole but this problem can reappear later on.
Attached is a text file containing listing of original z80 code, the user peephole used and the resulting invalid code.
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.4.0 (Feb 23 2004) (MINGW32)