[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Copy uint32 to Memory optimization?!

From: Moritz Struebe
Subject: [avr-gcc-list] Copy uint32 to Memory optimization?!
Date: Fri, 04 Jul 2008 11:07:56 +0200
User-agent: Thunderbird (Windows/20080421)

Hi there,

I just came past the following code. I'm optimizing with -Os.

static INLINE void setBeef(HEAPNODE * node){
*((u_long *) ((uptr_t) node + node->hn_size - sizeof(0xDEADBEEF))) = 0xDEADBEEF;
3c8:    8f ee           ldi    r24, 0xEF    ; 239
3ca:    9e eb           ldi    r25, 0xBE    ; 190
3cc:    ad ea           ldi    r26, 0xAD    ; 173
3ce:    be ed           ldi    r27, 0xDE    ; 222
3d0:    b2 93           st    -Z, r27
3d2:    a2 93           st    -Z, r26
3d4:    92 93           st    -Z, r25
3d6:    82 93           st    -Z, r24

The T register is already filled, so that's fine. But why are 4 additional registers needed? Doesn't the following code do the same? Especially as registers are quite valuable?

ldi    r24, 0xDE    ; 222
st    -Z, r24
ldi    r24, 0xAD    ; 173
st    -Z, r24
ldi    r24, 0xBE    ; 190
st    -Z, r24
ldi    r24, 0xEF    ; 239
st    -Z, r24

I'm neither too familiar with assembler nor compiler. Therefore an answer like: "Yes, your're right, but adding such an optimization is difficult / nobody was motivated to implement it." will satisfy me. ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]