https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114100

            Bug ID: 114100
           Summary: [avr] Inefficient indirect addressing on Reduced Tiny
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---

The Reduced Tiny core does not support indirect addressing with offset, which
basically means that every indirect memory access with a size of more than one
byte is effectively POST_INC or PRE_DEC.  The lack of that addressing mode is
currently handled by pretending to support it, and then let the insn printers
add and subtract again offsets as needed on the fly.

For example, the following C code

   int vars[10];

   void inc_var2 (void) {
      ++vars[2];
   }

is compiled to:

   ldi r30,lo8(vars)     ;  14   [c=4 l=2]  *movhi/4
   ldi r31,hi8(vars)
   subi r30,lo8(-(4))    ;  15   [c=8 l=6]  *movhi/2
   sbci r31,hi8(-(4))
   ld r20,Z+
   ld r21,Z
   subi r30,lo8((4+1))
   sbci r31,hi8((4+1))
   subi r20,-1             ;  16   [c=4 l=2]  *addhi3_clobber/1
   sbci r21,-1
   subi r30,lo8(-(4+1))    ;  17   [c=4 l=4]  *movhi/3
   sbci r31,hi8(-(4+1))
   st Z,r21
   st -Z,r20

where the code could be:

   ldi r30,lo8(vars+4)    ;  28   [c=4 l=2]  *movhi/4
   ldi r31,hi8(vars+4)
   ld r20,Z+              ;  17   [c=8 l=2]  *movhi/2
   ld r21,Z+
   subi r20,-1            ;  19   [c=4 l=2]  *addhi3_clobber/1
   sbci r21,-1
   st -Z,r21              ;  30   [c=4 l=2]  *movhi/3
   st -Z,r20

Reply via email to