[Bug target/37734] New: Missing optimization: gcc fails to reuse flags from already calculated expression for condition check with zero
siarhei dot siamashka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 4 02:41:00 GMT 2008
For the following source:
/****************************************/
extern void a();
int unrolled_loop_fn(int count)
{
while ((count -= 2) >= 0) {
a();
a();
}
if (count & 1) {
a();
}
}
/****************************************/
'gcc -O2 -c test.c' produces the following quite suboptimal code:
00000000 <unrolled_loop_fn>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 56 push %esi
4: 8b 75 08 mov 0x8(%ebp),%esi
7: 53 push %ebx
8: 83 ee 02 sub $0x2,%esi
b: 85 f6 test %esi,%esi
d: 89 f0 mov %esi,%eax
f: 78 1c js 2d <unrolled_loop_fn+0x2d>
11: 89 f3 mov %esi,%ebx
13: 90 nop
14: 8d 74 26 00 lea 0x0(%esi),%esi
18: e8 fc ff ff ff call 19 <unrolled_loop_fn+0x19>
1d: e8 fc ff ff ff call 1e <unrolled_loop_fn+0x1e>
22: 83 eb 02 sub $0x2,%ebx
25: 79 f1 jns 18 <unrolled_loop_fn+0x18>
27: 83 e6 01 and $0x1,%esi
2a: 8d 46 fe lea -0x2(%esi),%eax
2d: a8 01 test $0x1,%al
2f: 74 05 je 36 <unrolled_loop_fn+0x36>
31: e8 fc ff ff ff call 32 <unrolled_loop_fn+0x32>
36: 5b pop %ebx
37: 5e pop %esi
38: 5d pop %ebp
39: c3 ret
--
Summary: Missing optimization: gcc fails to reuse flags from
already calculated expression for condition check with
zero
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: siarhei dot siamashka at gmail dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37734
More information about the Gcc-bugs
mailing list