From owner-freebsd-current@FreeBSD.ORG Sat Sep 15 00:18:18 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 100081065672 for ; Sat, 15 Sep 2012 00:18:18 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id BABE18FC16 for ; Sat, 15 Sep 2012 00:18:17 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id q8F0I9in070225; Fri, 14 Sep 2012 17:18:09 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id q8F0I8cm070224; Fri, 14 Sep 2012 17:18:08 -0700 (PDT) (envelope-from sgk) Date: Fri, 14 Sep 2012 17:18:08 -0700 From: Steve Kargl To: Brooks Davis Message-ID: <20120915001808.GA70215@troutmask.apl.washington.edu> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120914202319.GB5244@lor.one-eyed-alien.net> User-Agent: Mutt/1.4.2.3i Cc: Ian Lepore , Tijl Coosemans , current@freebsd.org, Dimitry Andric , toolchain@freebsd.org, Nathan Whitehorn Subject: Re: Clang as default compiler November 4th X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2012 00:18:18 -0000 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 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