This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17481] Dead temporaries saved across function calls


------- Additional Comments From giovannibajo at libero dot it  2004-09-14 18:15 -------
With 4.0.0, with -O3 -DINLINE_FCALL, we get:

_Z4testRK9aggregateS1_S1_:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        movl    12(%ebp), %edx
        flds    (%edx)
        movl    16(%ebp), %edx
        flds    (%edx)
        movl    20(%ebp), %edx
        flds    (%edx)
        fld     %st(2)
        fadd    %st(2), %st
        fmul    %st(1), %st
        fld     %st(3)
        fadd    %st(2), %st
        fmul    %st(3), %st
        fxch    %st(3)
        faddp   %st, %st(2)
        fxch    %st(3)
        fmulp   %st, %st(1)
        faddp   %st, %st(1)
        faddp   %st, %st(1)
        fstps   (%eax)
        leave
        ret     $4


Notice that the code is more optimized, and the unused stack space is gone.
With simply -O3, we get:


_Z4testRK9aggregateS1_S1_:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $16, %esp
        movl    8(%ebp), %ebx
        movl    12(%ebp), %eax
        flds    (%eax)
        movl    16(%ebp), %eax
        flds    (%eax)
        movl    20(%ebp), %eax
        flds    (%eax)
        fld     %st(2)
        fadd    %st(2), %st
        fmul    %st(1), %st
        fld     %st(3)
        fadd    %st(2), %st
        fmul    %st(3), %st
        fxch    %st(3)
        faddp   %st, %st(2)
        fxch    %st(3)
        fmulp   %st, %st(1)
        faddp   %st, %st(1)
        faddp   %st, %st(1)
        fstps   -8(%ebp)
        leal    -8(%ebp), %eax
        pushl   %eax
        pushl   %ebx
        call    _Z5fcallRK9aggregate
        movl    %ebx, %eax
        movl    -4(%ebp), %ebx
        leave
        ret     $4


where all the useless code is gone.

This is another good example of how 4.0 does miracles with C++ code, thanks to 
the brand new tree optimizers. I close this bug as fixed in 4.0, as obviously 
it will not be fixed in any previous version.

Thanks for the report.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to fail|                            |3.3.1
      Known to work|                            |4.0.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]