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 rtl-optimization/15492] New: floating-point arguments are loaded too early to x87 stack


This testcase shows another problem with x87 stack:

double test (double a, double b) {
        return a*a +  b*b;
}

In this case, floating point arguments are loaded too early to x87 stack,
with 'gcc -O2', resulting asm is:
test:
        pushl   %ebp
        movl    %esp, %ebp
        fldl    8(%ebp)
        fldl    16(%ebp)
        fxch    %st(1)
        fmul    %st(0), %st
        fxch    %st(1)
        popl    %ebp
        fmul    %st(0), %st
        faddp   %st, %st(1)
        ret
 
The situation is a little better with '-O2 -fomit-frame-pointer':
test:
        fldl    4(%esp)
        fldl    12(%esp)
        fmul    %st(0), %st
        fxch    %st(1)
        fmul    %st(0), %st
        faddp   %st, %st(1)
        ret

But optimal code would look something like this (second arg should be loaded to
stack in some kind of 'just in time' fashion.
test:
        fldl    4(%esp)
        fmul    %st(0), %st
        fldl    12(%esp)
        fmul    %st(0), %st
        faddp   %st, %st(1)
        ret

-- 
           Summary: floating-point arguments are loaded too early to x87
                    stack
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uros at kss-loka dot si
                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: i686-pc-linux-gnu


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


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