The stm8 port currently lacks a peephole optimizer. This is a feature request to get the basic infrastructure for the peephole optimizer in place, as far as it is needed to optimize relative jumps.
For this, the function for instruction size needs to be implemented. See e.g. the z80 or mcs51 ports for an example.
Then a rule that converts jp into jr could be added to stm8/peeph.def (and once that is working, we can go for rules that invert jump conditions, etc).