From owner-freebsd-current@freebsd.org Sun Feb 14 22:00:10 2021 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34D1053EA86 for ; Sun, 14 Feb 2021 22:00:10 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Df1PM561bz4dsX for ; Sun, 14 Feb 2021 22:00:07 +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.16.1/8.16.1) with ESMTPS id 11ELxwxW080822 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Sun, 14 Feb 2021 13:59:59 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.16.1/8.16.1/Submit) id 11ELxwuH080821 for freebsd-current@freebsd.org; Sun, 14 Feb 2021 13:59:58 -0800 (PST) (envelope-from sgk) Date: Sun, 14 Feb 2021 13:59:58 -0800 From: Steve Kargl To: freebsd-current@freebsd.org Subject: HEADSUP: math is broken with clang and optimization Message-ID: <20210214215958.GA80810@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Queue-Id: 4Df1PM561bz4dsX X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=washington.edu (policy=none); spf=none (mx1.freebsd.org: domain of sgk@troutmask.apl.washington.edu has no SPF policy when checking 128.95.76.21) smtp.mailfrom=sgk@troutmask.apl.washington.edu X-Spamd-Result: default: False [-3.00 / 15.00]; RCVD_TLS_ALL(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[128.95.76.21:from]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[128.95.76.21:from:127.0.2.255]; ARC_NA(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:73, ipnet:128.95.0.0/16, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-current]; DMARC_POLICY_SOFTFAIL(0.10)[washington.edu : No valid SPF, No valid DKIM, none] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 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: Sun, 14 Feb 2021 22:00:10 -0000 Just a headsup for anyone doing numerical work with FreeBSD-current. clang with optimization of -O1 or higher produces wrong results. Testing 1 million complex values of ccoshf and limiting |z| < 20, shows % cc -o testf -O2 -pipe -static -Wall -fno-builtin \ -I/usr/home/kargl/include -I/usr/local/include -I../mp \ -I../libm/msun/src testf.c -L/usr/home/kargl/lib \ -L/usr/local/lib -L../mp -L../libm/msun -lmpsk -lmpfr -lgmp -lm % ./testf -u -n 1 -X 10 Max ULP Re: 136633.320045 Max ULP Im: 1890038.672637 % cc -o testf -O0 -pipe -static -Wall -fno-builtin \ -I/usr/home/kargl/include -I/usr/local/include -I../mp \ -I../libm/msun/src testf.c -L/usr/home/kargl/lib \ -L/usr/local/lib -L../mp -L../libm/msun -lmpsk -lmpfr -lgmp -lm % ./testf -u -n 1 -X 10 Max ULP Re: 2.785010 Max ULP Im: 2.926068 One of these is more correct than the other. -- Steve