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

            Bug ID: 109476
           Summary: Missing optimization for 8bit/8bit multiplication /
                    regression
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: klaus.doldinger64 at googlemail dot com
  Target Milestone: ---

For avr-gcc > 4.6.4 the follwing function

uint16_t mul(const uint8_t a, const uint16_t b) {
    return static_cast<uint8_t>((b >> 8) + 0) * a ;
}

produces suboptimal

mul(unsigned char, unsigned int):
        mov r18,r23
        ldi r19,0
        mov r20,r24
        mul r20,r18
        movw r24,r0
        mul r20,r19
        add r25,r0
        clr __zero_reg__
        ret

whereas avr-gcc 4.6.4 produces optimal

mul(unsigned char, unsigned int):
        mul r23,r24
        movw r24,r0
        clr r1
        ret

Reply via email to