From owner-freebsd-toolchain@freebsd.org Wed Mar 13 18:16:26 2019 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCF3A153C5C2; Wed, 13 Mar 2019 18:16:25 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 36DA48D8D7; Wed, 13 Mar 2019 18:16:25 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x2DIGN6e036104 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 13 Mar 2019 11:16:23 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x2DIGNOP036103; Wed, 13 Mar 2019 11:16:23 -0700 (PDT) (envelope-from sgk) Date: Wed, 13 Mar 2019 11:16:23 -0700 From: Steve Kargl To: Conrad Meyer Cc: John Baldwin , "freebsd-toolchain@FreeBSD.org" , freebsd-current Subject: Re: Optimization bug with floating-point? Message-ID: <20190313181623.GA36061@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20190313024506.GA31746@troutmask.apl.washington.edu> <20190313151635.GA34757@troutmask.apl.washington.edu> <20190313164039.GA35340@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) X-Rspamd-Queue-Id: 36DA48D8D7 X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [4.19 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; HAS_REPLYTO(0.00)[sgk@troutmask.apl.washington.edu]; TO_DN_SOME(0.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; RCVD_IN_DNSWL_MED(-0.20)[21.76.95.128.list.dnswl.org : 127.0.11.2]; MX_GOOD(-0.01)[cached: troutmask.apl.washington.edu]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:73, ipnet:128.95.0.0/16, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.82)[0.817,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.02)[ip: (0.09), ipnet: 128.95.0.0/16(0.08), asn: 73(0.01), country: US(-0.07)]; DMARC_NA(0.00)[washington.edu]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.71)[0.713,0]; RCVD_TLS_LAST(0.00)[]; NEURAL_SPAM_LONG(0.95)[0.948,0]; R_SPF_NA(0.00)[] X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 18:16:26 -0000 On Wed, Mar 13, 2019 at 10:40:28AM -0700, Conrad Meyer wrote: > Hi John, > > On Wed, Mar 13, 2019 at 10:17 AM John Baldwin wrote: > > One issue I'm aware of is that clang does not have any support for the > > special arrangement FreeBSD/i386 uses where it uses different precision > > for registers vs in-memory for some of the floating point types (GCC has > > a special hack that is only used on FreeBSD for this but isn't used on > > any other OS's). I wonder if that could be a factor? Volatile probably > > forces a round trip between memory which might explain why this is the > > case. > > > > I wonder what your test program does on i386 Linux with GCC? > > $ uname -sr > Linux 4.20.4 > $ gcc --version > gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6) > ... > $ rpm -qf /usr/lib/libm-2.27.so > glibc-2.27-37.fc28.i686 > > $ gcc -m32 -fno-builtin -o z kargl.c -lm && ./z > Max ULP: 1.959975 > Count: 0 > $ gcc -O -m32 -fno-builtin -o z kargl.c -lm && ./z > Max ULP: 1.959975 > Count: 0 > $ gcc -O1 -m32 -fno-builtin -o z kargl.c -lm && ./z > Max ULP: 1.959975 > Count: 0 > $ gcc -O2 -m32 -fno-builtin -o z kargl.c -lm && ./z > Max ULP: nan > Count: 0 > $ gcc -O3 -m32 -fno-builtin -o z kargl.c -lm && ./z > Max ULP: nan > Count: 0 > > Uh. > > kargl.c: In function ‘main’: > kargl.c:80:10: warning: ‘u’ may be used uninitialized in this function > [-Wmaybe-uninitialized] > if (ur > u) u = ur; > ^ Whoops. There are a number of variations on a theme named a.c. Initializing u to 0 doesn't change the outcome with clang on FreeBSD. -- Steve