This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

Re: fixed check for sinl in acinclude.m4



Perhaps I should rename these to: GLIBCPP_HAVE_NO_LIBRARY_REF_FOO.

Let's take a look at three cases: abs, sinf, and sqrt

here's the test for __builtin_abs:

#include <math.h>
int main()
{
  __builtin_abs(0.0);
  return 0;
}

gcc -O2 test.c on x86 gives:

.text
        .align 4
.globl main
        .type    main,@function
main:
        pushl %ebp
        movl %esp,%ebp
        xorl %eax,%eax
        movl %ebp,%esp
        popl %ebp
        ret

-> This is a builtin function with no external library references.
   v3 will mark this as builtin, and use this instead of a library call



here's the test for __builtin_sinf:

#include <math.h>

int main()
{
  __builtin_sinf(0.0);
  return 0;
}

        .align 4
.globl main
        .type    main,@function
main:
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        addl $-12,%esp
        pushl $0x0
        call sinf
        fstp %st(0)
        xorl %eax,%eax
        movl %ebp,%esp
        popl %ebp
        ret

-> This is a builtin function with external library references (sinf)
   v3 will not mark this as a builtin, and use sinf instead (if it's
   found) (since that's what's called anyway.)



here's the test for __builtin_sqrt:

#include <math.h>

int main()
{
  __builtin_sqrt(0.0);
  return 0;
}

.text
        .align 4
.globl main
        .type    main,@function
main:
        fldz
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        fsqrt
        fucomp %st(0)
        fnstsw %ax
        andb $69,%ah
        cmpb $64,%ah
        je .L310
        addl $-12,%esp
        pushl $0x0
        call sqrtf
        fstp %st(0)

-> This is a builtin function with external library references
   (sqrtf).  As you've noticed, yeah, it has some optimizations
   (fsqrt), but the library reference really throws systematic
   autoconf testing (see #2). If you can figure out how to allow this,
   but not mark #2 (sinf) as builtin, I'm interested. I don't think
   much more effort on this is going to be worthwhile though... 

   Again, the float overloads are misleading: the real problem is the
   long-double overloads, where the glibc 2.1 headers for
   alpha/powerpc don't have declarations in math.h yet have
   definitions in libm.a. Thus the AC_CHEC_FUNC tests give invalid (or
   incomplete) information for the purposes of the c++ library. This
   was the problem with the previous approach to testing math
   functions.... I've spent too much time on this already: what we
   have now is correct and mostly optimal.


-benjamin


ps. you can get free alpha accounts at testdrive.compaq.com. 

pps. if you can find somebody to give you a G4, hell, even a G3, lemme
know. Put me on that list. I'm working on a 200 Mhz 604.



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