With this patch I get with make -C support/regression test-ucgbz80
:
Summary for 'ucgbz80': 1 abnormal stops ( ), 2101 failures, 16829 tests, 2384 test cases, 3921650 bytes, 990177747 ticks
But
ld a, #0 sbc a, (hl)
and
sbc a, a sub a, (hl)
are equivalent code:
http://z80-heaven.wikidot.com/optimization#toc18
Most curious fail is bug-1918.c, the only change was:
- sbc a, a - sub a, (hl) + ld a, #0x00 + sbc a, (hl) ld a, #0x00
$ bin/sdcc -v SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.7 #12058 (Linux) published under GNU General Public License (GPL)
replace {
ld a, #%1
sbc a, (hl)
} by {
; common peephole 122b optimized carry substraction by 0.
sbc a, a
sub a, (hl)
}
Both code results same value in A but they are producing different C flag. C flag of LD version does not depend on the C value before the code. But SBC version produces C which depends on starting C value.
Daniel
Yes thanks, it's not a bug then and I have to limit the rules with
notUsed('f')
I bumped into this old and closed item, but I don't understand how both codes are different. Sure the incoming carry isn't used in LD, but it also doesn't modify the carry either, right?
Should in my mind be equal to:
So if this fails regression tests then I suspect a problem in the simulator.
no carry:
If there is no carry, it shouldn’t matter.
carry:
This makes a difference
0-0-1 has a carry, but -1-0 doesn’t.
Ah, right. Sorry for the noise.