Dear all,

I am working on a GCC port and I have a problem with the code
generation for this architecture. Consider this code:

void f (int buff[]) {
   buff[0] += 16;
   buff[1] += 32;
}

void g (int buff[]) {
   buff[0] = 64;
   buff[1] = 128;
}

I get this output:
0000000000000000 <f>:
ldw r7,0(r8)
addi r7,r7,16
stw r7,0(r8)
addi r7,r8,4
ldw r6,0(r7)
addi r6,r6,32
stw r6,0(r7)

However, I would prefer to use the offsets during loads and stores in
order to get :
0000000000000000 <f>:
ldw r7, 0(r8)
addi r7, r7, 16
stw r7, 0(r8)
ldw r7, 4(r8)
addi r7, r7, 32
stw r7, 4(r8)

For the function g, I get:
0000000000000020 <g>:
li r7,0x40
stw r7,0(r8)
li r7,0x80
stw r7,4(r8)

which uses the offset for the store.

Does anybody have ideas why there is a difference between the code
generation both functions or where in the GCC code this is performed
or why the compiler behaves differently for both functions would be
greatly appreciated!

Thanks in advance,
Jc

Reply via email to