public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/18980] New: i386 libm functions return with excess range and precision
@ 2015-09-18 16:56 jsm28 at gcc dot gnu.org
  2015-09-18 17:06 ` [Bug math/18980] " jsm28 at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-09-18 16:56 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18980

            Bug ID: 18980
           Summary: i386 libm functions return with excess range and
                    precision
           Product: glibc
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: jsm28 at gcc dot gnu.org
  Target Milestone: ---

Various i386 libm functions return values with excess range and precision,
which now causes testsuite failures after Wilco Dijkstra's patches to make
isfinite etc. expand inline (the issue, however, was there in previous
releases, just less visible).

This bug is specifically about the following functions (and not any others),
where the excess range now causes test failures: (for float, double or both)
cosh, sinh, exp, exp10/pow10, exp2, expm1, hypot, pow, lgamma/gamma.  Any other
functions seen to have such issues with different compilers should have
separate bugs filed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/18980] i386 libm functions return with excess range and precision
  2015-09-18 16:56 [Bug math/18980] New: i386 libm functions return with excess range and precision jsm28 at gcc dot gnu.org
@ 2015-09-18 17:06 ` jsm28 at gcc dot gnu.org
  2015-09-18 20:01 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-09-18 17:06 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18980

--- Comment #1 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Example failures for float:

Failure: cosh (-0x2.c5d374p+12): Exception "Overflow" not set

Failure: Test: cosh_downward (-0x2.c5d374p+12)
Result:
 is:          inf   inf
 should be:   3.40282346638528859811e+38   0x1.fffffe00000000000000p+127

I believe the mechanism is that previously the wrapper would call __finitef,
thereby forcing a return with excess range to overflow.  Now, isfinite, without
-fexcess-precision=standard, knows nothing about the excess precision, compares
with FLT_MAX and deduces independent of the rounding mode that the value with
excess precision is infinite, so resulting in __kernel_standard_f returning an
infinity (also without overflow exception resulting) independent of the
rounding mode.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/18980] i386 libm functions return with excess range and precision
  2015-09-18 16:56 [Bug math/18980] New: i386 libm functions return with excess range and precision jsm28 at gcc dot gnu.org
  2015-09-18 17:06 ` [Bug math/18980] " jsm28 at gcc dot gnu.org
@ 2015-09-18 20:01 ` cvs-commit at gcc dot gnu.org
  2015-09-18 21:54 ` cvs-commit at gcc dot gnu.org
  2015-09-18 21:55 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-09-18 20:01 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18980

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  c8235dda728c4452f57c4c0d1bccc4e9a67da80c (commit)
      from  fe8c2b33aed067282ecac0cc3fdff1feef88548b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c8235dda728c4452f57c4c0d1bccc4e9a67da80c

commit c8235dda728c4452f57c4c0d1bccc4e9a67da80c
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri Sep 18 20:00:48 2015 +0000

    Avoid excess range overflowing results from cosh, sinh, lgamma (bug 18980).

    Various i386 libm functions return values with excess range and
    precision; Wilco Dijkstra's patches to make isfinite etc. expand
    inline cause this pre-existing issue to result in test failures (when
    e.g. a result that overflows float but not long double gets counted as
    overflowing for some purposes but not others).

    This patch addresses those cases arising from functions defined in C,
    adding a math_narrow_eval macro that forces values to memory to
    eliminate excess precision if FLT_EVAL_METHOD indicates this is
    needed, and is a no-op otherwise.  I'll convert existing uses of
    volatile and asm for this purpose to use the new macro later, once
    i386 has clean test results again (which requires fixes for .S files
    as well).

    Tested for x86_64 and x86.  Committed.

        [BZ #18980]
        * sysdeps/generic/math_private.h: Include <float.h>.
        (math_narrow_eval): New macro.
        [FLT_EVAL_METHOD != 0] (excess_precision): Likewise.
        * sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Use
        math_narrow_eval on overflowing return value.
        * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r):
        Likewise.
        * sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise.
        * sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Likewise.
        * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r):
        Likewise.
        * sysdeps/ieee754/flt-32/e_sinhf.c (__ieee754_sinhf): Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                            |   16 ++++++++++++++++
 sysdeps/generic/math_private.h       |   24 ++++++++++++++++++++++++
 sysdeps/ieee754/dbl-64/e_cosh.c      |    2 +-
 sysdeps/ieee754/dbl-64/e_lgamma_r.c  |    2 +-
 sysdeps/ieee754/dbl-64/e_sinh.c      |    2 +-
 sysdeps/ieee754/flt-32/e_coshf.c     |    2 +-
 sysdeps/ieee754/flt-32/e_lgammaf_r.c |    2 +-
 sysdeps/ieee754/flt-32/e_sinhf.c     |    2 +-
 8 files changed, 46 insertions(+), 6 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/18980] i386 libm functions return with excess range and precision
  2015-09-18 16:56 [Bug math/18980] New: i386 libm functions return with excess range and precision jsm28 at gcc dot gnu.org
  2015-09-18 17:06 ` [Bug math/18980] " jsm28 at gcc dot gnu.org
  2015-09-18 20:01 ` cvs-commit at gcc dot gnu.org
@ 2015-09-18 21:54 ` cvs-commit at gcc dot gnu.org
  2015-09-18 21:55 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-09-18 21:54 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18980

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  6f0f237bf5a3c8d29a6342cbf8b4c17b10aa1d4c (commit)
      from  1344384b52829a4dcde51ec3a307c4b3d6a713fa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6f0f237bf5a3c8d29a6342cbf8b4c17b10aa1d4c

commit 6f0f237bf5a3c8d29a6342cbf8b4c17b10aa1d4c
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri Sep 18 21:53:22 2015 +0000

    Avoid excess range in results from i386 exp, hypot, pow functions (bug
18980).

    i386 exp, hypot and pow functions can return overflowing and
    underflowing values with excess range and precision; ; Wilco
    Dijkstra's patches to make isfinite etc. expand inline cause this
    pre-existing issue to result in test failures.

    This patch fixes those functions to avoid excess range and precision
    in their return values.  Appropriate macros are added for the repeated
    code sequences; in future I'll add more such macros and refactor
    existing code forcing underflow (with or without also eliminating
    excess range and precision from the return value) to use such macros.

    Tested for x86.  If, after this patch, you still see x86 libm test
    failures with excess range or precision, please file bugs in Bugzilla.

        [BZ #18980]
        * sysdeps/i386/fpu/i386-math-asm.h (DEFINE_FLT_MIN): New macro.
        (DEFINE_DBL_MIN): Likewise.
        (FLT_NARROW_EVAL_UFLOW_NONNEG_NAN): Likewise.
        (DBL_NARROW_EVAL_UFLOW_NONNEG_NAN): Likewise.
        (FLT_NARROW_EVAL_UFLOW_NONNEG): Likewise.
        (DBL_NARROW_EVAL_UFLOW_NONNEG): Likewise.
        * sysdeps/i386/fpu/e_exp.S: Include <i386-math-asm.h>.
        (dbl_min): Replace with use of DEFINE_DBL_MIN.
        (__ieee754_exp): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
        (__exp_finite): Use DBL_NARROW_EVAL_UFLOW_NONNEG.
        * sysdeps/i386/fpu/e_exp10.S: Include <i386-math-asm.h>.
        (dbl_min): Replace with use of DEFINE_DBL_MIN.
        (__ieee754_exp10): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
        * sysdeps/i386/fpu/e_exp10f.S: Include <i386-math-asm.h>.
        (flt_min): Replace with use of DEFINE_FLT_MIN.
        (__ieee754_exp10f): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
        * sysdeps/i386/fpu/e_exp2.S: Include <i386-math-asm.h>.
        (dbl_min): Replace with use of DEFINE_DBL_MIN.
        (__ieee754_exp2): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
        * sysdeps/i386/fpu/e_exp2f.S: Include <i386-math-asm.h>.
        (flt_min): Replace with use of DEFINE_FLT_MIN.
        (__ieee754_exp2f): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
        * sysdeps/i386/fpu/e_expf.S: Include <i386-math-asm.h>.
        (flt_min): Replace with use of DEFINE_FLT_MIN.
        (__ieee754_expf): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
        (__expf_finite): Use FLT_NARROW_EVAL_UFLOW_NONNEG.
        * sysdeps/i386/fpu/e_hypot.S: Include <i386-math-asm.h>.
        (__ieee754_hypot): Use DBL_NARROW_EVAL.
        * sysdeps/i386/fpu/e_hypotf.S: Include <i386-math-asm.h>.
        (__ieee754_hypotf): Use FLT_NARROW_EVAL.
        * sysdeps/i386/fpu/e_pow.S: Include <i386-math-asm.h>.
        (__ieee754_pow): Use DBL_NARROW_EVAL.
        * sysdeps/i386/fpu/e_powf.S: Include <i386-math-asm.h>.
        (__ieee754_powf): Use FLT_NARROW_EVAL.
        * sysdeps/i386/i686/fpu/multiarch/e_expf-sse2.S
        (__ieee754_expf_sse2): Convert double-precision result to single
        precision.
        * sysdeps/i386/fpu/libm-test-ulps: Update.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                     |   42 +++++
 NEWS                                          |    2 +-
 sysdeps/i386/fpu/e_exp.S                      |   44 +----
 sysdeps/i386/fpu/e_exp10.S                    |   26 +---
 sysdeps/i386/fpu/e_exp10f.S                   |   26 +---
 sysdeps/i386/fpu/e_exp2.S                     |   26 +---
 sysdeps/i386/fpu/e_exp2f.S                    |   26 +---
 sysdeps/i386/fpu/e_expf.S                     |   44 +----
 sysdeps/i386/fpu/e_hypot.S                    |    2 +
 sysdeps/i386/fpu/e_hypotf.S                   |    2 +
 sysdeps/i386/fpu/e_pow.S                      |    3 +
 sysdeps/i386/fpu/e_powf.S                     |    3 +
 sysdeps/i386/fpu/i386-math-asm.h              |   87 +++++++++
 sysdeps/i386/fpu/libm-test-ulps               |  233 +++++++++++++------------
 sysdeps/i386/i686/fpu/multiarch/e_expf-sse2.S |    9 +-
 15 files changed, 292 insertions(+), 283 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/18980] i386 libm functions return with excess range and precision
  2015-09-18 16:56 [Bug math/18980] New: i386 libm functions return with excess range and precision jsm28 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-09-18 21:54 ` cvs-commit at gcc dot gnu.org
@ 2015-09-18 21:55 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-09-18 21:55 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18980

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.23

--- Comment #4 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 2.23.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-18 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 16:56 [Bug math/18980] New: i386 libm functions return with excess range and precision jsm28 at gcc dot gnu.org
2015-09-18 17:06 ` [Bug math/18980] " jsm28 at gcc dot gnu.org
2015-09-18 20:01 ` cvs-commit at gcc dot gnu.org
2015-09-18 21:54 ` cvs-commit at gcc dot gnu.org
2015-09-18 21:55 ` jsm28 at gcc dot gnu.org

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).