View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038285 | FPC | Compiler | public | 2020-12-31 11:06 | 2020-12-31 16:53 |
Reporter | Christo Crause | Assigned To | Florian | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 3.3.1 | ||||
Fixed in Version | 3.3.1 | ||||
Summary | 0038285: AVR [patch] Fix missed optimization opportunities | ||||
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. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 47915 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
aoptcpu.patch (1,207 bytes)
diff --git a/compiler/avr/aoptcpu.pas b/compiler/avr/aoptcpu.pas index b64a27df71..031633d92f 100644 --- a/compiler/avr/aoptcpu.pas +++ b/compiler/avr/aoptcpu.pas @@ -423,7 +423,7 @@ Implementation DebugMsg('Peephole LdiOp2Opi performed', p); - RemoveCurrentP(p); + result:=RemoveCurrentP(p); end; end; end; @@ -447,6 +447,7 @@ Implementation taicpu(p).loadconst(0,taicpu(p).oper[0]^.ref^.offset) else taicpu(p).loadconst(0,taicpu(p).oper[0]^.ref^.offset-32); + result:=true; end; A_LDS: if (taicpu(p).oper[1]^.ref^.symbol=nil) and @@ -468,6 +469,8 @@ Implementation taicpu(p).loadconst(1,taicpu(p).oper[1]^.ref^.offset) else taicpu(p).loadconst(1,taicpu(p).oper[1]^.ref^.offset-32); + + result:=true; end; A_IN: if GetNextInstruction(p,hp1) then |
|
Thanks, applied. |
|
Thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-12-31 11:06 | Christo Crause | New Issue | |
2020-12-31 11:06 | Christo Crause | File Added: aoptcpu.patch | |
2020-12-31 16:36 | Florian | Assigned To | => Florian |
2020-12-31 16:36 | Florian | Status | new => resolved |
2020-12-31 16:36 | Florian | Resolution | open => fixed |
2020-12-31 16:36 | Florian | Fixed in Version | => 3.3.1 |
2020-12-31 16:36 | Florian | Fixed in Revision | => 47915 |
2020-12-31 16:36 | Florian | FPCTarget | => - |
2020-12-31 16:36 | Florian | Note Added: 0127975 | |
2020-12-31 16:53 | Christo Crause | Status | resolved => closed |
2020-12-31 16:53 | Christo Crause | Note Added: 0127977 |