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

            Bug ID: 93587
           Summary: [RX] bclr,bnot,bset on byte memory with bit 7 not
                    fused
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: olegendo at gcc dot gnu.org
  Target Milestone: ---

The bit manipulation of bit 7 in a byte variable doesn't get fused into a
single instruction.

void bleh_0 (uint8_t* x, uint8_t* y, uint8_t* z)
{
  *x ^= 1 << 7;
  *y |= 1 << 7;
  *z &= ~(1 << 7);
}

compiles to:
        mov.B   [r1], r14
        xor     #-128, r14
        mov.B   r14, [r1]
        mov.B   [r2], r14
        or      #-128, r14
        mov.B   r14, [r2]
        mov.B   [r3], r14
        and     #0x7f, r14
        mov.B   r14, [r3]
        rts


while other bit positions like 

void bleh_1 (uint8_t* x, uint8_t* y, uint8_t* z)
{
  *x ^= 1 << 6;
  *y |= 1 << 6;
  *z &= ~(1 << 6);
}

compile to:
        bnot    #6, [r1].B
        bset    #6, [r2].B
        bclr    #6, [r3].B
        rts

Reply via email to