[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] Strange asm output
From: |
Paul Schlie |
Subject: |
Re: [avr-libc-dev] Strange asm output |
Date: |
Wed, 10 Nov 2004 21:38:11 -0500 |
User-agent: |
Microsoft-Entourage/11.1.0.040913 |
GCC Bug 18424 has been added to the database:
3.4.3 generates code which may be ~6x+ slower and larger than 3.3.1 @ -0s
as it apparently no longer evaluates constant expression trees in anything
other than simple expressions for some reason, which may result in serious
performance and code size regressions, which should really be fixed if
possible.
// 000000c6 <foo>:
int foo ( int a ){
if (a & (1L << 23))
// c6: aa 27 eor r26, r26
// c8: 97 fd sbrc r25, 7
// ca: a0 95 com r26
// cc: ba 2f mov r27, r26
// ce: 27 e1 ldi r18, 0x17 ; 23
// d0: b6 95 lsr r27
// d2: a7 95 ror r26
// d4: 97 95 ror r25
// d6: 87 95 ror r24
// d8: 2a 95 dec r18
// da: d1 f7 brne .-12 ; 0xd0
// dc: 81 70 andi r24, 0x01 ; 1
// de: 90 70 andi r25, 0x00 ; 0
// e0: 89 2b or r24, r25
// e2: 19 f0 breq .+6 ; 0xea
return 1;
// e4: 81 e0 ldi r24, 0x01 ; 1
// e6: 90 e0 ldi r25, 0x00 ; 0
// e8: 08 95 ret
else
return 2 ;
// ea: 82 e0 ldi r24, 0x02 ; 2
// ec: 90 e0 ldi r25, 0x00 ; 0
}
// ee: 08 95 ret
// f0: 08 95 ret
// where the second return is odd as well?
vs GCC 3.3.1 @ -0s
// 000000c6 <foo>:
int foo ( int a ){
if (a & (1L << 23))
return 1;
else
return 2 ;
}
// c6: 82 e0 ldi r24, 0x02 ; 2
// c8: 90 e0 ldi r25, 0x00 ; 0
// ca: 08 95 ret
(where for referance int targeted to avr is 16-bits wide,
but the above problem is not likely target sensitive.)
Which I hope will get someone's attention.
> From: Nicolas Schodet <address@hidden>
> Date: Thu, 11 Nov 2004 00:43:35 +0100
> To: <address@hidden>
> Subject: Re: [avr-libc-dev] Strange asm output
>
> * Dmitry K. <address@hidden> [041110 23:50]:
>>> I have a little piece of code which produce a very strange code:
>>> I can not understand why gcc do not just test the 23th bit.
>> I have try:
>> [...]
>
> I change my original code, so I writed a new one:
>
> /* toto.c */
> #include <inttypes.h>
>
> int32_t
> toto (int32_t a)
> {
> if (a & (1L << 23))
> return 1;
> else
> return 0;
> }
>
> Command line:
>
> avr-gcc -g -Wall -O2 -mmcu=atmega128 -MMD -S -o toto.s toto.c
>
> Gcc version:
>
> avr-gcc (GCC) 3.4.1
>
> Result:
>
> .global toto
> .type toto, @function
> toto:
> .stabn 68,0,6,.LM1-toto
> .LM1:
> /* prologue: frame size=0 */
> /* prologue end (size=0) */
> movw r26,r24
> movw r24,r22
> .stabn 68,0,7,.LM2-toto
> .LM2:
> ldi r18,23
> 1: lsr r27
> ror r26
> ror r25
> ror r24
> dec r18
> brne 1b
> andi r24,lo8(1)
> andi r25,hi8(1)
> or r24,r25
> breq .L2
> .stabn 68,0,8,.LM3-toto
> .LM3:
> ldi r22,lo8(1)
> ldi r23,hi8(1)
> ldi r24,hlo8(1)
> ldi r25,hhi8(1)
> ret
> .L2:
> .stabn 68,0,10,.LM4-toto
> .LM4:
> ldi r22,lo8(0)
> ldi r23,hi8(0)
> ldi r24,hlo8(0)
> ldi r25,hhi8(0)
> .stabn 68,0,11,.LM5-toto
> .LM5:
> ret
> /* epilogue: frame size=0 */
> ret
> /* epilogue end (size=1) */
> /* function toto size 24 (23) */
> .size toto, .-toto
>
> Tell me if you need more informations.
>
> /Nicolas
>
>
> _______________________________________________
> AVR-libc-dev mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-libc-dev
- [avr-libc-dev] Strange asm output, Nicolas Schodet, 2004/11/09
- Re: [avr-libc-dev] Strange asm output, Dmitry K., 2004/11/10
- 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 <=
- 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
- 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., Dmitry K., 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