[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] loop deleted using optimization
From: |
alee |
Subject: |
[avr-gcc-list] loop deleted using optimization |
Date: |
Tue, 06 Mar 2007 13:49:18 -1000 |
User-agent: |
Mozilla Thunderbird 1.0.7 (X11/20050923) |
Why does avr-gcc delete my empty "for" loops if I compile with
optimization on?
I am able to preserve the loop if I add a NOP in the loop but that will
eat up one clock cycle. Is there a way to preserve the empty loops
without adding any NOP clock cycles? Is this a bug? Below is a test C
code and the avr-gcc generated asm:
///////////* C code /////////////*/
int main(void)
{ int counton, countoff;
int tempcount;
do
{
counton = 27; countoff=1700; //should div by 23
for(tempcount = 0; tempcount < counton; tempcount++)
{ ;
}
for(tempcount = 0; tempcount < countoff; tempcount++)
{;
}
}
while(1);
return 0;
}
///////* ASM code /////////////*/
main:
/* prologue: frame size=0 */
ldi r28,lo8(__stack - 0)
ldi r29,hi8(__stack - 0)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
ldi r24,lo8(0)
ldi r25,hi8(0)
rjmp .L12
.L4:
adiw r24,1
.L12:
cpi r24,27
cpc r25,__zero_reg__
brlt .L4
ldi r24,lo8(0)
ldi r25,hi8(0)
rjmp .L12
/* epilogue: frame size=0 */
- [avr-gcc-list] loop deleted using optimization,
alee <=