Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Dave Daney
Sat, 01 Aug 1992 14:37
non optimal code from -O2 on an 80386
Author: Dave Daney
Date: Sat, 01 Aug 1992 14:37
Date: Sat, 01 Aug 1992 14:37
101 lines
2873 bytes
2873 bytes
Here is a question for the maintainers of the gcc optimizer for the
80386. consider this file:
// file test.cc used to show the (non) optimizer problem.---------
class tree_element {
int value;
tree_element *larger;
tree_element *smaller;
tree_element *parent;
int num_larger;
int num_smaller;
public:
int get() {return value;};
int get_value() {return value;};
tree_element(int i);
~tree_element();
friend class binary_tree;
};
tree_element::tree_element(int i)
{
value = i;
num_larger = num_smaller = 0;
parent = larger = smaller = 0;
}
tree_element::~tree_element()
{
if(larger) delete larger;
if(smaller) delete smaller;
}
//--------<end>---------------------------------------
Compiled thusly on Interactive 2.2.1 (SysV/386 R3.2):
> gcc -v -O2 -S test.cc
Reading specs from /usr/local/lib/gcc-lib/i386-isc/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/i386-isc/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dunix -Di386 -D__unix__ -D__i386__ -D__unix -D__i386 -D__OPTIMIZE__ test.cc /usr/tmp/cca01388.i
GNU CPP version 2.2.2 (80386, ATT syntax)
/usr/local/lib/gcc-lib/i386-isc/2.2.2/cc1plus /usr/tmp/cca01388.i -quiet -dumpbase test.cc -O2 -version -o test.s
GNU C++ version 2.2.2 (80386, ATT syntax) compiled by GNU C version 2.2.2.
> cat test.s
.file "test.cc"
gcc2_compiled.:
.text
.align 4
.globl __12tree_elementi
__12tree_elementi:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movl 12(%ebp),%edx
movl %edx,(%eax)
movl $0,20(%eax)
movl $0,16(%eax)
movl $0,8(%eax)
movl $0,4(%eax)
movl $0,12(%eax)
leave
ret
.align 4 <----------why two of these??
.align 4
.globl _._12tree_element
_._12tree_element:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
cmpl $0,4(%ebx)
je .L8 <----------why two of these??
je .L8
pushl $3
pushl 4(%ebx)
call _._12tree_element
addl $8,%esp
.L8:
cmpl $0,8(%ebx)
je .L14 <----------why two of these??
je .L14
pushl $3
pushl 8(%ebx)
call _._12tree_element
addl $8,%esp
.L14:
movb 12(%ebp),%al
andb $1,%al
je .L16
pushl %ebx
call __builtin_delete
.L16:
movl -4(%ebp),%ebx
leave
ret
>
I hope they are not in there as two byte nop's for alignment, because they
don't cause any thing to become aligned (jump targets or instructions following
calls)
Dave Daney daney@mermaid.micro.umn.edu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads