public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vogt at linux dot vnet.ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug go/63269] libgo/math test failures in TestLog2
Date: Wed, 05 Nov 2014 16:47:00 -0000	[thread overview]
Message-ID: <bug-63269-4-jKCZvnfFKg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-63269-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63269

--- Comment #5 from Dominik Vogt <vogt at linux dot vnet.ibm.com> ---
regarding 1)

My earlier explanation of the problem was wrong.  Multiply and add is not
generated; it probably only was in the artificial test case that I made and
certainly did not compile with -ffp-contract=off.

In this calculation in log2(),

  Log(frac)*(1/Ln2) + float64(exp)

Gcc does constant folding for (1/Ln2) and generates a multiply instruction and
then adds the second term.  Same result if you write "*Log2E" instead of
"*(1/Ln2)").  But with

  Log(frac)/Ln2 + float64(exp)

it generates a divide instruction.  The multiplication and the division yield
results that differ in the least significant bit, and I don't see how this
could be prevented in general; it's just an artifact of the floating point
format.  I've verified that the constants Ln2, 1/Ln2 and Log2E are bit correct.

The "easy" way to fix this is increasing the allowed tolerance as my patch does
(note that the arguments of the veryclose() call need to be swapped, see
previous comment).

The "right" way to fix this is to calculate platform specific ULPs for all the
algorithms from the math library and use these.  That's what glibc does.


  parent reply	other threads:[~2014-11-05 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 14:10 [Bug go/63269] New: " vogt at linux dot vnet.ibm.com
2014-09-15 14:12 ` [Bug go/63269] " vogt at linux dot vnet.ibm.com
2014-09-17  8:35 ` vogt at linux dot vnet.ibm.com
2014-11-05  3:54 ` ian at airs dot com
2014-11-05 14:34 ` vogt at linux dot vnet.ibm.com
2014-11-05 16:47 ` vogt at linux dot vnet.ibm.com [this message]
2014-11-06 10:18 ` vogt at linux dot vnet.ibm.com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-63269-4-jKCZvnfFKg@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).