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

            Bug ID: 101226
           Summary: Suboptimal codegen for >>/>>>
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: maxsamukha at gmail dot com
  Target Milestone: ---
            Target: AVR

example.d:

void f1()
{
    __gshared ubyte value;
    value >>>= 5;
}

void f2()
{
    __gshared ubyte value;
    value = value >>> 5;
}

----
avr-gcc -fno-druntime -O3 example.d:

example.f1():
        lds r24,example.f1().value
        swap r24
        lsr r24
        andi r24,lo8(7)
        sts example.f1().value,r24
        ret
example.f2():
        lds r24,example.f2().value
        ldi r25,0
        ldi r27,0
        ldi r26,0
        ldi r18,5
        1:
        lsr r27
        ror r26
        ror r25
        ror r24
        dec r18
        brne 1b
        sts example.f2().value,r24
        ret

The compiler apparently fails to optimize out the integer promotion for >>> in
f2 and produces inefficient machine code.

Reply via email to