gcc-2.95.2 non-optimal inlining
Thomas Peterson
tompeterson@mn.mediaone.net
Tue Apr 18 17:52:00 GMT 2000
Gcc fails to perform optimal inlining for the following example. If I
rearrange the value1() and value2() functions then it produces the
optimal code. The Borland compiler is able to produce optimal code
without rearrangement. Shouldn't gcc be capable of producing the
optimal code without rearrangement of the functions?
Tom
mn65-buck$ cat tester.cpp
class Tester
{
public:
int value1()
{
return value2();
}
int value2 ()
{
return 3;
}
int value3();
};
int Tester::value3()
{
return value1();
}
mn65-buck$ powerpc-motorola-elf-gcc.exe -O3 -c tester.cpp
mn65-buck$ powerpc-motorola-elf-objdump --source --disassemble-all
--demangle --reloc tester.o
tester.o: file format elf32-powerpc
Disassembly of section .text:
00000000 <Tester::value3(void)>:
0: 94 21 ff f0 stwu r1,-16(r1)
4: 7c 08 02 a6 mflr r0
8: 90 01 00 14 stw r0,20(r1)
c: 48 00 00 01 bl c <Tester::value3(void)+0xc>
c: R_PPC_REL24 Tester::value2(void)
10: 80 01 00 14 lwz r0,20(r1)
14: 7c 08 03 a6 mtlr r0
18: 38 21 00 10 addi r1,r1,16
1c: 4e 80 00 20 blr
Disassembly of section .data:
Disassembly of section .gnu.linkonce.t.value2__6Tester:
00000000 <Tester::value2(void)>:
0: 38 60 00 03 li r3,3
4: 4e 80 00 20 blr
mn65-buck$
More information about the Gcc-bugs
mailing list