Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Sep 2012 17:18:08 -0700
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        Brooks Davis <brooks@freebsd.org>
Cc:        Ian Lepore <freebsd@damnhippie.dyndns.org>, Tijl Coosemans <tijl@coosemans.org>, current@freebsd.org, Dimitry Andric <dim@freebsd.org>, toolchain@freebsd.org
Subject:   Re: Clang as default compiler November 4th
Message-ID:  <20120915001808.GA70215@troutmask.apl.washington.edu>
In-Reply-To: <20120914202319.GB5244@lor.one-eyed-alien.net>
References:  <20120911120649.GA52235@freebsd.org> <20120911132410.GA87126@troutmask.apl.washington.edu> <504F4645.4070900@FreeBSD.org> <504F4A6B.4010001@coosemans.org> <504F5101.8090906@FreeBSD.org> <505101C3.70203@freebsd.org> <20120913020833.GA8255@troutmask.apl.washington.edu> <1347550332.1110.108.camel@revolution.hippie.lan> <20120913161024.GA13846@troutmask.apl.washington.edu> <20120914202319.GB5244@lor.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 14, 2012 at 03:23:19PM -0500, Brooks Davis wrote:
> On Thu, Sep 13, 2012 at 09:10:24AM -0700, Steve Kargl wrote:
> > ok 1 - cexp zero
> > Abort trap (core dumped)
> > *** [tests] Error code 134
> > 
> > Stop in /usr/src/tools/regression/lib/msun.
> 
> Prompted by this post, I did a bit of testing and it looks like we have
> two classes of failures that need to be investigated.  First, some tests
> are failing with a gcc compiled world and clang compiled test code.
> They seem to mostly be unexpected fp exception state when testing with
> NaNs.  I suspect that someone more knowledgeable in this area could come
> up with a reduced test case and explication of what clang is doing wrong
> pretty quickly.
> 
> The second class is tests that fail when libm is compiled using clang.
> I've not investigate those at all.  I'd tend to guess that we have a
> wider range of issues there.
> 

A third class of failure appears to be that clang emits
i387 fpu instructions for at least sinf and cosf instead 
of calls to the library routines.  AFAIK, the library
routines are faster and more accurate.

% cat a.c
#include <math.h>
float
foo(float x) {
   float a;
   a = sinf(x) * cosf(x);
   return (a);
}

% clang -S -O a.c

foo:                                    # @foo
# BB#0:                                 # %entry
        flds    4(%esp)
        fld     %st(0)
        fcos
        fxch
        fsin
        fmulp
        ret

% cc -S -O a.c

foo:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $20, %esp
        movl    8(%ebp), %ebx
        movl    %ebx, (%esp)
        call    sinf
        fstps   -8(%ebp)
        movl    %ebx, (%esp)
        call    cosf
        fmuls   -8(%ebp)
        addl    $20, %esp
        popl    %ebx
        popl    %ebp
        ret

% clang -S -O -fno-builtin a.c
foo:                                    # @foo
# BB#0:                                 # %entry
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        flds    8(%ebp)
        fsts    -16(%ebp)               # 4-byte Folded Spill
        fstps   (%esp)
        calll   sinf
        fstpt   -12(%ebp)               # 10-byte Folded Spill
        flds    -16(%ebp)               # 4-byte Folded Reload
        fstps   (%esp)
        calll   cosf
        fldt    -12(%ebp)               # 10-byte Folded Reload
        fmulp
        addl    $24, %esp
        popl    %ebp
        ret

Using -fno-builtin would seem to be a non-starter in that it
disables all builtin functions.

-- 
Steve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120915001808.GA70215>