public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/11830] New: Unnecessary call to an empty function
@ 2003-08-06  9:26 alga at rgai dot hu
  2003-08-06 12:08 ` [Bug optimization/11830] " pinskia at physics dot uc dot edu
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: alga at rgai dot hu @ 2003-08-06  9:26 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830

           Summary: Unnecessary call to an empty function
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alga at rgai dot hu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf

If a (non-virtual) function doesn't have any instructions or the caller
function(s) are not dependent on the result of the called function
(which is hard to identify), then the function call instruction is
unnecessary at the caller.
The unit-at-a-time algorithm doesn't solve this problem either.

--- c example ---
int a,b;
int get(int i)
{
  return i;
}
void foo()
{
  a=10;
  b=get(a);
}

--- arm code ---
get:
 mov pc, lr <- RETURN
foo:
 ldr r2, .L3
 mov r3, #10
 mov ip, sp
 stmfd sp!, {fp, ip, lr, pc}
 mov r0, r3
 str r3, [r2, #0]
 sub fp, ip, #4
 bl get <- OLD
 ldr r3, .L3+4
 str r0, [r3, #0]
 ldmea fp, {fp, sp, pc} 

--- possible solution ---
get:
 mov pc, lr <- RETURN
foo:
 ldr r2, .L3
 mov r3, #10
 mov ip, sp
 stmfd sp!, {fp, ip, lr, pc}
 mov r0, r3
 str r3, [r2, #0]
 sub fp, ip, #4
 ldr r3, .L3+4
 str r0, [r3, #0]
 ldmea fp, {fp, sp, pc}


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
@ 2003-08-06 12:08 ` pinskia at physics dot uc dot edu
  2003-08-06 12:49 ` rearnsha at arm dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-06 12:08 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-06 12:08:33
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-06 12:08 -------
In your example , you depend on the result of the call so you cannot remove the function 
call because b is global (unless GCC can see all of your code).
But here is an example where GCC does not remove the function at all (confirmed on the 
mainline 20030806):
int a;
int get(int i)
{
  return i;
}
void foo()
{
  int b;
  a=10;
  b= get(a);
}


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
  2003-08-06 12:08 ` [Bug optimization/11830] " pinskia at physics dot uc dot edu
@ 2003-08-06 12:49 ` rearnsha at arm dot com
  2003-08-06 13:06 ` pinskia at physics dot uc dot edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: rearnsha at arm dot com @ 2003-08-06 12:49 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830



------- Additional Comments From rearnsha at arm dot com  2003-08-06 12:49 -------
Subject: Re:  Unnecessary call to an empty 
 function

> In your example , you depend on the result of the call so you cannot remove the function 
> call because b is global (unless GCC can see all of your code).
> But here is an example where GCC does not remove the function at all (confirmed on the 
> mainline 20030806):
> int a;
> int get(int i)
> {
>   return i;
> }
> void foo()
> {
>   int b;
>   a=10;
>   b= get(a);
> }

Gcc will do these types of optimization with -finline-functions.  However, 
that can make code bigger (the inlining code really needs some work to 
make it more conservative with -Ospace).

R.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
  2003-08-06 12:08 ` [Bug optimization/11830] " pinskia at physics dot uc dot edu
  2003-08-06 12:49 ` rearnsha at arm dot com
@ 2003-08-06 13:06 ` pinskia at physics dot uc dot edu
  2003-08-15  3:41 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-06 13:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|arm-unknown-elf             |
   Target Milestone|3.4                         |tree-ssa


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-06 13:06 -------
The tree-ssa branch does not optimize this either but it is most likely will do so in the 
future.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
                   ` (2 preceding siblings ...)
  2003-08-06 13:06 ` pinskia at physics dot uc dot edu
@ 2003-08-15  3:41 ` pinskia at gcc dot gnu dot org
  2003-10-26 20:32 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-15  3:41 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2003-08-06 12:08:33         |2003-08-15 03:41:50
               date|                            |


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-15 03:41 -------
If I get rid of the assignment of b (in my example or yours) GCC does remove the function 
call.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
                   ` (3 preceding siblings ...)
  2003-08-15  3:41 ` pinskia at gcc dot gnu dot org
@ 2003-10-26 20:32 ` pinskia at gcc dot gnu dot org
  2003-11-05 13:19 ` alga at rgai dot hu
  2003-11-13  8:43 ` alga at rgai dot hu
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-26 20:32 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|tree-ssa                    |---


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-26 20:28 -------
Actually this was fixed for 3.0.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
                   ` (4 preceding siblings ...)
  2003-10-26 20:32 ` pinskia at gcc dot gnu dot org
@ 2003-11-05 13:19 ` alga at rgai dot hu
  2003-11-13  8:43 ` alga at rgai dot hu
  6 siblings, 0 replies; 9+ messages in thread
From: alga at rgai dot hu @ 2003-11-05 13:19 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830



------- Additional Comments From alga at rgai dot hu  2003-11-05 13:19 -------
pinskia at gcc dot gnu dot org wrote:
> Actually this was fixed for 3.0.

I did not understand it clearly. This was fixed for 3.0.x, but
the mainline still contains it? Why?

I made some test with different arm-elf-gcc versions
(3.0, 3.0.1, 3.1, 3.2, 3.3, 3.4),
and I found no one solved the problem (with -Os).

I think this bug has to be reopened
because of the mainline (at least).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
  2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
                   ` (5 preceding siblings ...)
  2003-11-05 13:19 ` alga at rgai dot hu
@ 2003-11-13  8:43 ` alga at rgai dot hu
  6 siblings, 0 replies; 9+ messages in thread
From: alga at rgai dot hu @ 2003-11-13  8:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From alga at rgai dot hu  2003-11-13 08:43 -------
(In reply to comment #6)
See my earlier comment.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug optimization/11830] Unnecessary call to an empty function
       [not found] <20030806092603.11830.loki@inf.u-szeged.hu>
@ 2004-04-03  1:11 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-03  1:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-03 01:11 -------
Fixed in 3.5.0, sorry for closing this before, I did not understand the bug which you were 
reporting.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11830


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-04-03  1:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-06  9:26 [Bug optimization/11830] New: Unnecessary call to an empty function alga at rgai dot hu
2003-08-06 12:08 ` [Bug optimization/11830] " pinskia at physics dot uc dot edu
2003-08-06 12:49 ` rearnsha at arm dot com
2003-08-06 13:06 ` pinskia at physics dot uc dot edu
2003-08-15  3:41 ` pinskia at gcc dot gnu dot org
2003-10-26 20:32 ` pinskia at gcc dot gnu dot org
2003-11-05 13:19 ` alga at rgai dot hu
2003-11-13  8:43 ` alga at rgai dot hu
     [not found] <20030806092603.11830.loki@inf.u-szeged.hu>
2004-04-03  1:11 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).