View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038173 | FPC | Compiler | public | 2020-12-06 07:49 | 2020-12-06 18:36 |
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 | 0038173: AVR [patch] Use LDS for 8 bit references | ||||
Description | Loading an 8 bit reference into a register can be done more compactly when using LDS, rather than LDI + LD, see example below. The check for CPUAVR_16_REGS as per r47612 has been extended to tcg.a_op_ref. | ||||
Steps To Reproduce | program test; var b: byte; procedure dummy; begin if b > 0 then b := not(b) else inc(b); end; begin dummy; end. | ||||
Additional Information | Compiled with ~/fpc/3.3.1/compiler/ppcrossavr -n @~/fpc/3.3.1/fpc.cfg -O3 -Wpattiny13 test.lpr the generated code size is 138 bytes, compiled with the patch it is 130 bytes. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 47700 | ||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
8bitref.patch (2,015 bytes)
diff --git a/compiler/cgobj.pas b/compiler/cgobj.pas index ccd51fb2eb..24e0af97ec 100644 --- a/compiler/cgobj.pas +++ b/compiler/cgobj.pas @@ -2001,7 +2001,9 @@ implementation if assigned(ref.symbol) { for avrtiny, the code generator generates a ref which is Z relative and while using it, Z is changed, so the following code breaks } - {$ifdef avr}and not(CPUAVR_16_REGS in cpu_capabilities[current_settings.cputype]){$endif avr} then + {$ifdef avr} + and not((CPUAVR_16_REGS in cpu_capabilities[current_settings.cputype]) or (tcgsize2size[size]=1)) + {$endif avr} then begin tmpreg:=getaddressregister(list); a_loadaddr_ref_reg(list,ref,tmpreg); @@ -2037,7 +2039,9 @@ implementation if assigned(ref.symbol) { for avrtiny, the code generator generates a ref which is Z relative and while using it, Z is changed, so the following code breaks } - {$ifdef avr}and not(CPUAVR_16_REGS in cpu_capabilities[current_settings.cputype]){$endif avr} then + {$ifdef avr} + and not((CPUAVR_16_REGS in cpu_capabilities[current_settings.cputype]) or (tcgsize2size[size]=1)) + {$endif avr} then begin tmpreg:=getaddressregister(list); a_loadaddr_ref_reg(list,ref,tmpreg); @@ -2273,7 +2277,12 @@ implementation begin if not (Op in [OP_NOT,OP_NEG]) then internalerror(2020050710); - if assigned(ref.symbol) then + if assigned(ref.symbol) + { for avrtiny, the code generator generates a ref which is Z relative and while using it, + Z is changed, so the following code breaks } + {$ifdef avr} + and not((CPUAVR_16_REGS in cpu_capabilities[current_settings.cputype]) or (tcgsize2size[size]=1)) + {$endif avr} then begin tmpreg:=getaddressregister(list); a_loadaddr_ref_reg(list,ref,tmpreg); |
|
Thanks, applied. |
|
Thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-12-06 07:49 | Christo Crause | New Issue | |
2020-12-06 07:49 | Christo Crause | File Added: 8bitref.patch | |
2020-12-06 17:40 | Florian | Assigned To | => Florian |
2020-12-06 17:40 | Florian | Status | new => resolved |
2020-12-06 17:40 | Florian | Resolution | open => fixed |
2020-12-06 17:40 | Florian | Fixed in Version | => 3.3.1 |
2020-12-06 17:40 | Florian | Fixed in Revision | => 47700 |
2020-12-06 17:40 | Florian | FPCTarget | => - |
2020-12-06 17:40 | Florian | Note Added: 0127376 | |
2020-12-06 18:36 | Christo Crause | Status | resolved => closed |
2020-12-06 18:36 | Christo Crause | Note Added: 0127379 |