This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33725] New: Could eliminate argument push for the second const function for same arguments
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Oct 2007 12:58:06 -0000
- Subject: [Bug c/33725] New: Could eliminate argument push for the second const function for same arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This testcase:
--cut here--
extern const int foo (int a);
extern const int bar (int a);
int test (int a)
{
return foo (a) + bar (a);
}
--cut here--
compiles to:
test:
subl $12, %esp
movl %ebx, 4(%esp)
movl 16(%esp), %ebx
movl %esi, 8(%esp)
movl %ebx, (%esp) (*)
call foo
movl %ebx, (%esp) (**)
movl %eax, %esi
call bar
movl 4(%esp), %ebx
addl %esi, %eax
movl 8(%esp), %esi
addl $12, %esp
ret
However, since argument is already pushed to the stack for foo(), there is no
need to push it again for the bar() function [foo() is const function]. If gcc
eliminates the second push, a call-clobbered reg could be used to move argument
to (esp), resulting in something like:
test:
subl $12, %esp
movl 16(%esp), %eax
movl %esi, 8(%esp)
movl %eax, (%esp)
call foo
movl %eax, %esi
call bar
addl %esi, %eax
movl 8(%esp), %esi
addl $12, %esp
ret
--
Summary: Could eliminate argument push for the second const
function for same arguments
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ubizjak at gmail dot com
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33725