AVR [patch] Fix missed optimization opportunities
Original Reporter info from Mantis: ccrause @ccrause
-
Reporter name: Christo Crause
Original Reporter info from Mantis: ccrause @ccrause
- Reporter name: Christo Crause
Description:
Some of the optimizations in PeepHoleOptPass1 do not return true, thus preventing possible further optimizations in short units.
An example of this is shown below. It is expected that the intermediate code generated should trigger the InOriOut2Sbi optimization, however the optimizer didn't perform an extra pass because the previous Lds2In optimization didn't return true. This happens even at -O4.
Attached please find a patch that sets result for all optimizations that previously didn't set result to fix this specific problem and other potential missed opportunities.
Steps to reproduce:
program sbitest;
begin
EECR := EECR or 4;
end.
Compile with /fpc/3.3.1/compiler/ppcrossavr -Tembedded -Pavr -MObjFPC -Scghim -O2 -gw3 -vewnhibq -n @/fpc/3.3.1/fpc.cfg -Wpatmega328p -XPavr- -al sbitest.pp
Note generated code:
# [15] EECR := EECR or 4;
in r18,31
ori r18,4
out 31,r18
This isn't the expected sbi instruction.
Mantis conversion info:
- Mantis ID: 38285
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47915 (#4353d365)