This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/18424] [3.4/4.0 Regression] ~6x+ performance regression, constant trees not being computed.
- From: "schlie at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Dec 2004 08:02:10 -0000
- Subject: [Bug middle-end/18424] [3.4/4.0 Regression] ~6x+ performance regression, constant trees not being computed.
- References: <20041111023501.18424.schlie@comcast.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From schlie at comcast dot net 2004-12-21 08:02 -------
Problems, with 4.0 avr test results (some good, some bad, some odd);
000000c6 <main>:
int main (void){
c6: c8 ef ldi r28, 0xF8 ; 248
c8: d0 e1 ldi r29, 0x10 ; 16
ca: de bf out 0x3e, r29 ; 62
cc: cd bf out 0x3d, r28 ; 61
volatile char c;
volatile int i;
volatile long l;
/* char tests */
c = (c & (1 << 4));
ce: 89 81 ldd r24, Y+1 ; 0x01
d0: 80 71 andi r24, 0x10 ; 16 ; good.
d2: 89 83 std Y+1, r24 ; 0x01
if (c & (1 << 4))
d4: 89 81 ldd r24, Y+1 ; 0x01
d6: 84 ff sbrs r24, 4 ; good single bit test & branch
d8: 03 c0 rjmp .+6 ; 0xe0 <main+0x1a>
c = 1;
da: 81 e0 ldi r24, 0x01 ; 1
dc: 89 83 std Y+1, r24 ; 0x01
de: 01 c0 rjmp .+2 ; 0xe2 <main+0x1c>
else
c = 0;
e0: 19 82 std Y+1, r1 ; 0x01
c = (c & (1 << 4)) ? 1 : 0;
e2: 89 81 ldd r24, Y+1 ; 0x01
e4: 99 27 eor r25, r25
e6: 44 e0 ldi r20, 0x04 ; 4 ; bad, using shift loop. although same as above.
e8: 96 95 lsr r25
ea: 87 95 ror r24
ec: 4a 95 dec r20
ee: e1 f7 brne .-8 ; 0xe8 <main+0x22>
f0: 81 70 andi r24, 0x01 ; 1
f2: 89 83 std Y+1, r24 ; 0x01
c = sizeof(char);
f4: 81 e0 ldi r24, 0x01 ; 1
f6: 89 83 std Y+1, r24 ; 0x01
/* int tests */
i = i & (1 << 10);
f8: 8a 81 ldd r24, Y+2 ; 0x02
fa: 9b 81 ldd r25, Y+3 ; 0x03
fc: 80 70 andi r24, 0x00 ; 0 ; ok, but nicer if recognized only highest byte significant.
fe: 94 70 andi r25, 0x04 ; 4
100: 8a 83 std Y+2, r24 ; 0x02
102: 9b 83 std Y+3, r25 ; 0x03
if (i & (1 << 10))
104: 8a 81 ldd r24, Y+2 ; 0x02
106: 9b 81 ldd r25, Y+3 ; 0x03
108: 9c 01 movw r18, r24 ; shouldn't be moving the operand? rest as above.
10a: 20 70 andi r18, 0x00 ; 0
10c: 34 70 andi r19, 0x04 ; 4
10e: 92 ff sbrs r25, 2
110: 05 c0 rjmp .+10 ; 0x11c <main+0x56>
i = 1;
112: 81 e0 ldi r24, 0x01 ; 1
114: 90 e0 ldi r25, 0x00 ; 0 ; r1 = 0 already?,
116: 8a 83 std Y+2, r24 ; 0x02
118: 9b 83 std Y+3, r25 ; 0x03
11a: 02 c0 rjmp .+4 ; 0x120 <main+0x5a>
else
i = 0;
11c: 2a 83 std Y+2, r18 ; 0x02
11e: 3b 83 std Y+3, r19 ; 0x03 ; wrong, r19 = andi r19, 0x04 ?
i = (i & (1 << 10)) ? 1 : 0;
120: 8a 81 ldd r24, Y+2 ; 0x02
122: 9b 81 ldd r25, Y+3 ; 0x03
124: 89 2f mov r24, r25 ; nice, shifts by 8 first.
126: 99 27 eor r25, r25
128: 86 95 lsr r24
12a: 86 95 lsr r24
12c: 81 70 andi r24, 0x01 ; 1
12e: 90 70 andi r25, 0x00 ; 0 ; but then fogets it already set r25 to 0?
130: 8a 83 std Y+2, r24 ; 0x02
132: 9b 83 std Y+3, r25 ; 0x03
i = sizeof(int);
134: 82 e0 ldi r24, 0x02 ; 2
136: 90 e0 ldi r25, 0x00 ; 0
138: 8a 83 std Y+2, r24 ; 0x02
13a: 9b 83 std Y+3, r25 ; 0x03
/* long tests */
l = (l & ((long)1 << 26));
13c: 8c 81 ldd r24, Y+4 ; 0x04
13e: 9d 81 ldd r25, Y+5 ; 0x05
140: ae 81 ldd r26, Y+6 ; 0x06
142: bf 81 ldd r27, Y+7 ; 0x07
144: 80 70 andi r24, 0x00 ; 0 ; ok.
146: 90 70 andi r25, 0x00 ; 0
148: a0 70 andi r26, 0x00 ; 0
14a: b4 70 andi r27, 0x04 ; 4
14c: 8c 83 std Y+4, r24 ; 0x04
14e: 9d 83 std Y+5, r25 ; 0x05
150: ae 83 std Y+6, r26 ; 0x06
152: bf 83 std Y+7, r27 ; 0x07
if (l & ((long)1 << 26))
154: 8c 81 ldd r24, Y+4 ; 0x04
156: 9d 81 ldd r25, Y+5 ; 0x05
158: ae 81 ldd r26, Y+6 ; 0x06
15a: bf 81 ldd r27, Y+7 ; 0x07
15c: 9c 01 movw r18, r24 ; again unnessisarily moving things?
15e: ad 01 movw r20, r26
160: 20 70 andi r18, 0x00 ; 0 ; very odd, both &'s
162: 30 70 andi r19, 0x00 ; 0
164: 40 70 andi r20, 0x00 ; 0
166: 54 70 andi r21, 0x04 ; 4
168: b2 ff sbrs r27, 2 ; and tests the significant bit, didn't need to do above.
16a: 09 c0 rjmp .+18 ; 0x17e <main+0xb8>
l = 1;
16c: 81 e0 ldi r24, 0x01 ; 1
16e: 90 e0 ldi r25, 0x00 ; 0 ; again r1 = 0 already?
170: a0 e0 ldi r26, 0x00 ; 0
172: b0 e0 ldi r27, 0x00 ; 0
174: 8c 83 std Y+4, r24 ; 0x04
176: 9d 83 std Y+5, r25 ; 0x05
178: ae 83 std Y+6, r26 ; 0x06
17a: bf 83 std Y+7, r27 ; 0x07
17c: 04 c0 rjmp .+8 ; 0x186 <main+0xc0>
else
l = 0;
17e: 2c 83 std Y+4, r18 ; 0x04
180: 3d 83 std Y+5, r19 ; 0x05
182: 4e 83 std Y+6, r20 ; 0x06
184: 5f 83 std Y+7, r21 ; 0x07 ; wrong r21 = andi r21, 0x04
l = (l & ((long)1 << 26)) ? 1 : 0;
186: 8c 81 ldd r24, Y+4 ; 0x04
188: 9d 81 ldd r25, Y+5 ; 0x05
18a: ae 81 ldd r26, Y+6 ; 0x06
18c: bf 81 ldd r27, Y+7 ; 0x07
18e: 2a e1 ldi r18, 0x1A ; 26
190: b6 95 lsr r27 ; not good, big shift loop, should & or just test most sig. byte.
192: a7 95 ror r26
194: 97 95 ror r25
196: 87 95 ror r24
198: 2a 95 dec r18
19a: d1 f7 brne .-12 ; 0x190 <main+0xca>
19c: aa 27 eor r26, r26
19e: 97 fd sbrc r25, 7
1a0: a0 95 com r26
1a2: ba 2f mov r27, r26
1a4: 81 70 andi r24, 0x01 ; 1
1a6: 90 70 andi r25, 0x00 ; 0
1a8: a0 70 andi r26, 0x00 ; 0
1aa: b0 70 andi r27, 0x00 ; 0
1ac: 8c 83 std Y+4, r24 ; 0x04
1ae: 9d 83 std Y+5, r25 ; 0x05
1b0: ae 83 std Y+6, r26 ; 0x06
1b2: bf 83 std Y+7, r27 ; 0x07
l = sizeof(long);
1a8: 84 e0 ldi r24, 0x04 ; 4
1aa: 90 e0 ldi r25, 0x00 ; 0
1ac: a0 e0 ldi r26, 0x00 ; 0
1ae: b0 e0 ldi r27, 0x00 ; 0
1b0: 8c 83 std Y+4, r24 ; 0x04
1b2: 9d 83 std Y+5, r25 ; 0x05
1b4: ae 83 std Y+6, r26 ; 0x06
1b6: bf 83 std Y+7, r27 ; 0x07
return 0;
}
1b8: 80 e0 ldi r24, 0x00 ; 0
1ba: 90 e0 ldi r25, 0x00 ; 0
1bc: 0c 94 e0 00 jmp 0x1c0 <_exit>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18424