[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] Strange asm output
From: |
Dmitry K. |
Subject: |
Re: [avr-libc-dev] Strange asm output |
Date: |
Thu, 11 Nov 2004 08:51:44 +1000 |
User-agent: |
KMail/1.5 |
8 Nov 2004 02:52 Nicolas Schodet wrote:
> Hello,
>
> I have a little piece of code which produce a very strange code:
>
> int32_t a;
>
> if (a & (1L << 23))
> 1f6: da 01 movw r26, r20
> 1f8: c9 01 movw r24, r18
> 1fa: 77 e1 ldi r23, 0x17 ; 23
> 1fc: b6 95 lsr r27
> 1fe: a7 95 ror r26
> 200: 97 95 ror r25
> 202: 87 95 ror r24
> 204: 7a 95 dec r23
> 206: d1 f7 brne .-12 ; 0x1fc
> 208: 81 70 andi r24, 0x01 ; 1
> 20a: 90 70 andi r25, 0x00 ; 0
> 20c: 89 2b or r24, r25
> 20e: 51 f0 breq .+20 ; 0x224
>
> I can not understand why gcc do not just test the 23th bit.
I have try:
int foo (long x)
{
if (x & (1L<<23))
return 1001;
else
return 1002;
}
with:
avr-gcc 3.3.4 / mcu=atmega8
I have receive for -O1/-O2/-Os:
foo:
movw r26,r24
movw r24,r22
sbrs r26,7
rjmp .L2
ldi r24,lo8(1001)
ldi r25,hi8(1001)
ret
.L2:
ldi r24,lo8(1002)
ldi r25,hi8(1002)
ret
And for -O3:
foo:
sbrs r24,7
rjmp .L2
ldi r24,lo8(1001)
ldi r25,hi8(1001)
ret
.L2:
ldi r24,lo8(1002)
ldi r25,hi8(1002)
ret
Give, please, more piece of this program.
- [avr-libc-dev] Strange asm output, Nicolas Schodet, 2004/11/09
- Re: [avr-libc-dev] Strange asm output,
Dmitry K. <=
- Re: [avr-libc-dev] Strange asm output, Nicolas Schodet, 2004/11/10
- Re: [avr-libc-dev] Strange asm output, Dmitry K., 2004/11/10
- Re: [avr-libc-dev] Strange asm output, Paul Schlie, 2004/11/10
- Re: [avr-libc-dev] Strange asm output, Paul Schlie, 2004/11/11
- Re: [avr-libc-dev] Strange asm output, Nicolas Schodet, 2004/11/11
- Re: [avr-libc-dev] Strange asm output, Paul Schlie, 2004/11/11
- [avr-libc-dev] soliciting feedback/thoughts on potential value of a few gcc 4.0 tweaks., Paul Schlie, 2004/11/19
- Re: [avr-libc-dev] soliciting feedback/thoughts on potential value of a few gcc 4.0 tweaks., Theodore A. Roth, 2004/11/19
- Re: [avr-libc-dev] soliciting feedback/thoughts on potential value of a few gcc 4.0 tweaks., Paul Schlie, 2004/11/20
- Re: [avr-libc-dev] soliciting feedback/thoughts on potential value of a few gcc 4.0 tweaks., Bob Paddock, 2004/11/19