- one more
The mcs51 peephole optimizer has seen little activity for a while. I put
together a small set of changes to refresh it and spark a batch of new rules,
and would appreciate review.
I held them back until after the release rather than add to the pre-release rush.
Now seems like a good time to put them forward.
The work is split into small, mostly independent patches:
ph01_peephdef_comments ignore // comments when scanning for the next rule
ph02_operand_offset add the operandOffset condition function
ph03_tail_flag add the 'tail' rule modifier
ph04_retrack_hook add the 'retrack' port hook and rule modifier
fixed_regbank add --fixed-regbank (skip the ISR PSW reset when the program stays on register bank 0), with a diagnostic if a function uses __using
mcs51_peeph.def add missing liveness guards to several existing rules that could drop the accumulator or carry
mcs51_psw_idx track the non-carry PSW flags, harden the peephole liveness analysis, and fix a findLabel internal error on space-separated jump operands
mcs51_sloc_deadstore let notUsed() prove a store to a spill location dead (optional; separate on purpose)
sdccman_peephole document operandOffset / tail / retrack in the manual
peep_mcs51.def the new mcs51 peephole rules.
The patches apply from the trunk root and were generated against trunk
revision r16673.
Each patch was built against current trunk. The mcs51 regression suite
passes with no regressions in any memory model (small, medium, large, huge),
so generated code looks correct. I also compiled a corpus of about 20 real
8051 projects with and without the changes: the new rules fire on real code
(a few thousand hits across the corpus).
Rule-level and liveness correctness is easy to get subtly wrong.
I have tried to be careful and to guard each rule, but I am sure there are rough edges I have not seen, and would welcome review on any part,
so corrections and suggestions are very welcome.