Takayuki, thank you for the quick fix!

It seems works good now except only one degradation. Instead generating two 
instructions:


7               ptr += (i & 1);
   0x40078564 <+12>:    extui   a9, a8, 0, 1
   0x40078567 <+15>:    addx2   a2, a9, a2

Now it generates three:


7               ptr += (i & 1);
   0x40078564 <+12>:    extui   a9, a8, 0, 1
   0x40078567 <+15>:    addx2   a9, a9, a2
   0x4007856a <+18>:    mov.n   a2, a9


Testcase to reproduce:


#include <stdint.h>

__attribute__((noinline))
void * func (short *ptr, uint8_t count)
{
    for (unsigned i = 0; i < count; i++) {
        ptr += (i & 1);
    }
    return ptr;
}

int main(void)
{
    short buf[16] = {}; 
    func(buf, 16);
}

Reply via email to