------- Additional Comments From schlie at comcast dot net 2004-11-11 03:55
-------
Subject: Re: 3.4.3 ~6x+ performance regression vs
3.3.1, constant trees not being computed.
> pinskia at gcc dot gnu dot org <[EMAIL PROTECTED]> wrote:
> When I did 1 << 24 I got a warning (at least on the mainline on a cross to
> avr) about 24 being greater
> than the size of int so it was going to be 0. Again in real terms there is
> something on here but I really
> doubt it is a regression and you did not use -mint8 for the 3.3 build and not
> for the 3.4 build.
Yes, you're correct, (1 << 24) generates warnings: (not forcing -mmint8)
main.c: In function `foo1':
main.c:3: warning: left shift count >= width of type
main.c: In function `foo2':
main.c:12: warning: left shift count >= width of type
main.c: At top level:
main.c:21: warning: return type of 'main' is not `int'
and produces the anticipated correct code, sorry for the confusion.
---
However as reported with (1L << 24), it does not, nor should it yield
different results, but it appears to product the expected code only if
the same constant expression occurs in a simpler expression in the same
basic block: ?
File: main.lss:
main.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00800100 0000011e 000001b2 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 0000011e 00000000 00000000 00000094 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .bss 00000000 00800100 0000011e 000001b2 2**0
ALLOC
3 .noinit 00000000 00800100 00800100 000001b2 2**0
CONTENTS
4 .eeprom 00000000 00810000 00810000 000001b2 2**0
CONTENTS
5 .stab 000004c8 00000000 00000000 000001b4 2**2
CONTENTS, READONLY, DEBUGGING
6 .stabstr 0000044e 00000000 00000000 0000067c 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00000000 <__vectors>:
0: 0c 94 46 00 jmp 0x8c
4: 0c 94 61 00 jmp 0xc2
8: 0c 94 61 00 jmp 0xc2
c: 0c 94 61 00 jmp 0xc2
10: 0c 94 61 00 jmp 0xc2
14: 0c 94 61 00 jmp 0xc2
18: 0c 94 61 00 jmp 0xc2
1c: 0c 94 61 00 jmp 0xc2
20: 0c 94 61 00 jmp 0xc2
24: 0c 94 61 00 jmp 0xc2
28: 0c 94 61 00 jmp 0xc2
2c: 0c 94 61 00 jmp 0xc2
30: 0c 94 61 00 jmp 0xc2
34: 0c 94 61 00 jmp 0xc2
38: 0c 94 61 00 jmp 0xc2
3c: 0c 94 61 00 jmp 0xc2
40: 0c 94 61 00 jmp 0xc2
44: 0c 94 61 00 jmp 0xc2
48: 0c 94 61 00 jmp 0xc2
4c: 0c 94 61 00 jmp 0xc2
50: 0c 94 61 00 jmp 0xc2
54: 0c 94 61 00 jmp 0xc2
58: 0c 94 61 00 jmp 0xc2
5c: 0c 94 61 00 jmp 0xc2
60: 0c 94 61 00 jmp 0xc2
64: 0c 94 61 00 jmp 0xc2
68: 0c 94 61 00 jmp 0xc2
6c: 0c 94 61 00 jmp 0xc2
70: 0c 94 61 00 jmp 0xc2
74: 0c 94 61 00 jmp 0xc2
78: 0c 94 61 00 jmp 0xc2
7c: 0c 94 61 00 jmp 0xc2
80: 0c 94 61 00 jmp 0xc2
84: 0c 94 61 00 jmp 0xc2
88: 0c 94 61 00 jmp 0xc2
0000008c <__ctors_end>:
8c: 11 24 eor r1, r1
8e: 1f be out 0x3f, r1 ; 63
90: cf ef ldi r28, 0xFF ; 255
92: d0 e1 ldi r29, 0x10 ; 16
94: de bf out 0x3e, r29 ; 62
96: cd bf out 0x3d, r28 ; 61
00000098 <__do_copy_data>:
98: 11 e0 ldi r17, 0x01 ; 1
9a: a0 e0 ldi r26, 0x00 ; 0
9c: b1 e0 ldi r27, 0x01 ; 1
9e: ee e1 ldi r30, 0x1E ; 30
a0: f1 e0 ldi r31, 0x01 ; 1
a2: 02 c0 rjmp .+4 ; 0xa8
000000a4 <.do_copy_data_loop>:
a4: 05 90 lpm r0, Z+
a6: 0d 92 st X+, r0
000000a8 <.do_copy_data_start>:
a8: a0 30 cpi r26, 0x00 ; 0
aa: b1 07 cpc r27, r17
ac: d9 f7 brne .-10 ; 0xa4
000000ae <__do_clear_bss>:
ae: 11 e0 ldi r17, 0x01 ; 1
b0: a0 e0 ldi r26, 0x00 ; 0
b2: b1 e0 ldi r27, 0x01 ; 1
b4: 01 c0 rjmp .+2 ; 0xb8
000000b6 <.do_clear_bss_loop>:
b6: 1d 92 st X+, r1
000000b8 <.do_clear_bss_start>:
b8: a0 30 cpi r26, 0x00 ; 0
ba: b1 07 cpc r27, r17
bc: e1 f7 brne .-8 ; 0xb6
be: 0c 94 7c 00 jmp 0xf8
000000c2 <__bad_interrupt>:
c2: 0c 94 00 00 jmp 0x0
000000c6 <foo1>:
int foo1 ( 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
000000f2 <foo2>:
int foo2 ( int a ){
a = (a & (1L << 23));
if (a & (1L << 23))
return 1;
else
return 2 ;
}
f2: 82 e0 ldi r24, 0x02 ; 2
f4: 90 e0 ldi r25, 0x00 ; 0
f6: 08 95 ret
000000f8 <main>:
void main( void ){
f8: cd ef ldi r28, 0xFD ; 253
fa: d0 e1 ldi r29, 0x10 ; 16
fc: de bf out 0x3e, r29 ; 62
fe: cd bf out 0x3d, r28 ; 61
volatile int a;
a = foo1 ( a );
100: 89 81 ldd r24, Y+1 ; 0x01
102: 9a 81 ldd r25, Y+2 ; 0x02
104: 0e 94 63 00 call 0xc6
108: 89 83 std Y+1, r24 ; 0x01
10a: 9a 83 std Y+2, r25 ; 0x02
a = foo2 ( a );
10c: 89 81 ldd r24, Y+1 ; 0x01
10e: 9a 81 ldd r25, Y+2 ; 0x02
110: 0e 94 79 00 call 0xf2
114: 89 83 std Y+1, r24 ; 0x01
116: 9a 83 std Y+2, r25 ; 0x02
118: 0c 94 8e 00 jmp 0x11c
0000011c <_exit>:
11c: ff cf rjmp .-2 ; 0x11c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18424