The peephole optimizer that comes with sdcc is quite powerful and can be used to improve sdcc's output considerably.
sdcc has a number of weaknesses: it can't deal with statics, longs or floats efficiently. Statics are especially important because the best z80 performance comes from using them in preference to local variables when reasonable. But that's not the case with sdcc -- use of statics leads to poor code. Anyway, these problems can be fixed by the peephole optimizer and we've been doing that in z88dk. If you use sdcc through z88dk the code quality is much better.
The other problem sdcc has is it treats the z80 like a pure 8-bit processor and mostly ignores its 16-bit instructions. Again we can try to fix that in the peepholer but we can't always do that. sdcc sometimes swaps endianness in code which is not easy to fix.
Have a look at the state of things now when using sdcc through z88dk:
https://drive.google.com/file/d/0B6X...ew?usp=sharing
This program computes pi to 800 decimal places and we use it to benchmark 32-bit integer arithmetic. Both asm output file were compiled with sdcc using the z88dk libraries. "pi-sdcc.opt" is the code that sdcc generates by itself. "pi-z88dk.opt" is the code after z88dk applies its rules to improve it. It's much better and this is almost all due to sdcc's peephole optimizer.
Apart from the code generation side, there is no other z80 C compiler that is doing as much optimization in the front-end. It's just the code generation and libraries (written in C) that are weighing down sdcc.
[свернуть]